Replies: 1 comment
-
To fix the Here is how you can modify your code: from langchain.prompts import PromptTemplate
from langchain_ollama import ChatOllama
from langchain_core.output_parsers import SimpleJsonOutputParser
llm = ChatOllama(model="codellama:70b", temperature=0.5)
template = """<s>[INST] <<SYS>> {system_prompt} <</SYS>> {task_message} <<SYS>> {instruction_message} <</SYS>> [/INST] {model_answer_1} </s> <s>[INST] {user_message_2} [/INST]"""
prompt = PromptTemplate(
input_variables=["system_prompt", "task_message", "instruction_message", "model_answer_1", "user_message_2"],
template=template
)
chain = prompt | llm | SimpleJsonOutputParser()
system_prompt = f"You are a helpful AI assistant skilled in {codelang} programming."
task_message = f"Can you help me improve this code as per the following instruction?\n\n{resObj} "
instruction_message = f"The instruction is as follows: \n\n{ReadyPrompt} "
model_answer_1 = "Certainly! I'd be happy to help improve your code. Let me analyze it for you. "
user_message_2 = "Please provide the improved code. Return your response in JSON format with a single key 'code' containing the improved code as a string. "
response = chain.invoke(
{
"system_prompt": system_prompt,
"task_message": task_message,
"instruction_message": instruction_message,
"model_answer_1": model_answer_1,
"user_message_2": user_message_2
}
)
print(response) Make sure to replace any calls to |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Checked other resources
Commit to Help
Example Code
Description
The code doesn't run: AttributeError: 'RunnableSequence' object has no attribute 'run'
System Info
langchain==0.2.8
langchain-community==0.2.7
langchain-core==0.2.34
langchain-ollama==0.1.1
langchain-text-splitters==0.2.2
Beta Was this translation helpful? Give feedback.
All reactions