Skip to content

Commit

Permalink
THUDM#870 修改为invoke
Browse files Browse the repository at this point in the history
  • Loading branch information
zRzRzRzRzRzRzR committed Feb 29, 2024
1 parent f53dcb1 commit a103d80
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions openai_api_demo/langchain_openai_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@


def initialize_llm_chain(messages: list):
template = "{question}"
template = "{input}"
prompt = PromptTemplate.from_template(template)

endpoint_url = "http://127.0.0.1:8000/v1/chat/completions"
Expand All @@ -28,7 +28,7 @@ def initialize_llm_chain(messages: list):


def get_ai_response(llm_chain, user_message):
ai_response = llm_chain.run(user_message)
ai_response = llm_chain.invoke({"input": user_message})
return ai_response


Expand All @@ -37,15 +37,15 @@ def continuous_conversation():
SystemMessage(content="You are an intelligent AI assistant, named ChatGLM3."),
]
while True:
user_input = input("Enter your question (or 'exit' to quit): ")
user_input = input("Human (or 'exit' to quit): ")
if user_input.lower() == 'exit':
break
llm_chain = initialize_llm_chain(messages=messages)
ai_response = get_ai_response(llm_chain, user_input)
print(ai_response)
print("ChatGLM3: ", ai_response["text"])
messages += [
HumanMessage(content=user_input),
AIMessage(content=ai_response),
AIMessage(content=ai_response["text"]),
]


Expand Down

0 comments on commit a103d80

Please sign in to comment.