from langchain.prompts.chat import ChatPromptTemplate
template = "You are a helpful assistant that translates {input_language} to {output_language}."
human_template = "{text}"
chat_prompt = ChatPromptTemplate.from_messages([
("system", template),
("human", human_template),
])
chat_prompt.format_messages(input_language="English", output_language="French", text="I love programming.")
< /code>
Но когда я запускаю приведенный выше код, я получаю следующую ошибку: < /p>
Traceback (most recent call last):
File "/home/yser364/Projets/SinappsIrdOpenaiQA/promptWorkout.py", line 6, in
chat_prompt = ChatPromptTemplate.from_messages([
File "/home/yser364/.local/lib/python3.10/site-packages/langchain/prompts/chat.py", line 220, in from_messages
return cls(input_variables=list(input_vars), messages=messages)
File "/home/yser364/.local/lib/python3.10/site-packages/langchain/load/serializable.py", line 64, in __init__
super().__init__(**kwargs)
File "pydantic/main.py", line 341, in pydantic.main.BaseModel.__init__
pydantic.error_wrappers.ValidationError: 4 validation errors for ChatPromptTemplate
messages -> 0
value is not a valid dict (type=type_error.dict)
messages -> 0
value is not a valid dict (type=type_error.dict)
messages -> 1
value is not a valid dict (type=type_error.dict)
messages -> 1
value is not a valid dict (type=type_error.dict)
Как показано в Langchain QuickStart, я пробую следующий код Python: < /p> [code]from langchain.prompts.chat import ChatPromptTemplate template = "You are a helpful assistant that translates {input_language} to {output_language}." human_template = "{text}"
chat_prompt.format_messages(input_language="English", output_language="French", text="I love programming.") < /code> Но когда я запускаю приведенный выше код, я получаю следующую ошибку: < /p> Traceback (most recent call last): File "/home/yser364/Projets/SinappsIrdOpenaiQA/promptWorkout.py", line 6, in chat_prompt = ChatPromptTemplate.from_messages([ File "/home/yser364/.local/lib/python3.10/site-packages/langchain/prompts/chat.py", line 220, in from_messages return cls(input_variables=list(input_vars), messages=messages) File "/home/yser364/.local/lib/python3.10/site-packages/langchain/load/serializable.py", line 64, in __init__ super().__init__(**kwargs) File "pydantic/main.py", line 341, in pydantic.main.BaseModel.__init__ pydantic.error_wrappers.ValidationError: 4 validation errors for ChatPromptTemplate messages -> 0 value is not a valid dict (type=type_error.dict) messages -> 0 value is not a valid dict (type=type_error.dict) messages -> 1 value is not a valid dict (type=type_error.dict) messages -> 1 value is not a valid dict (type=type_error.dict) [/code] Я использую Python 3.10.12.
The code works a few iterations of the following:
1) Creating vector store
2) Upload individual file (to ensure clean and singular context)
3) Call OpenAI's client.beta.threads.runs.create_and_poll
4) Output messages in a CSV format.
Код выполняет несколько итераций следующих операций:
Создание векторного хранилища
Загрузка отдельного файла (в обеспечить чистый и единый контекст)
Вызов «client.beta.threads.runs.create_and_poll» OpenAI
Вывод сообщений в формате CSV.
Я работаю над чат-ботом, использующим LangChain с моделью OpenAI gpt-3.5-turbo. Когда я использую метод LLMChain для объединения моего экземпляра ChatOpenAI, ChatPromptTemplate и StrOutputParser, все работает нормально, и ответы генерируются...
Я работаю над чат-ботом, использующим LangChain с моделью OpenAI gpt-3.5-turbo. Когда я использую метод LLMChain для объединения моего экземпляра ChatOpenAI, ChatPromptTemplate и StrOutputParser, все работает нормально, и ответы генерируются...
Это очень простой пример, как я пытаюсь использовать Langchain, чтобы вызвать LLM и найти инструмент для использования
import asyncio
import json
from langchain.agents import AgentExecutor, create_structured_chat_agent, Tool
from...