OutputParserException: не удалось проанализировать выходные данные LLM на ноутбуке Jupyter.Python

Программы на Python
Ответить Пред. темаСлед. тема
Anonymous
 OutputParserException: не удалось проанализировать выходные данные LLM на ноутбуке Jupyter.

Сообщение Anonymous »

Я столкнулся со следующей ошибкой в ​​блокноте conda

Код: Выделить всё

   File ~\.conda\envs\LLMS\lib\site-packages\langchain\agents\conversational\output_parser.py:26, in ConvoOutputParser.parse(self, text) 24 match = re.search(regex, text) 25 if not match: ---> 26     raise OutputParserException(f"Could not parse LLM output:
{text}`")
27 action = match.group(1)
28 action_input = match.group(2)

Код: Выделить всё

OutputParserException: Could not parse LLM output: `
Answer: "Hello, good morning. I am a helpful assistant.
Have a normal`
утро")`
Я также проверил https://python.langchain.com/docs/modul ... ing_errors< /p>
Я пробовал использовать ConversationalAgent и Initialize_agent, который имеет некоторые ограничения для моей цели.
Это код, который я пробовал
`

Код: Выделить всё

import os
from langchain.llms.huggingface_endpoint import HuggingFaceEndpoint
from langchain.llms import LlamaCpp
from langchain import PromptTemplate, LLMChain
from langchain.callbacks.manager import CallbackManager
from langchain.callbacks.streaming_stdout import StreamingStdOutCallbackHandler
import pandas as pd
from utils import *
llm_hf = HuggingFaceEndpoint(
endpoint_url="https://xxx",
huggingfacehub_api_token="xxx", task="text-generation"
)
from langchain.agents import create_sql_agent
from langchain.agents.agent_toolkits import SQLDatabaseToolkit
from langchain.sql_database import SQLDatabase
from langchain.llms.openai import OpenAI
from langchain.agents import AgentExecutor
from langchain.agents.agent_types import AgentType
from langchain.chat_models import ChatOpenAI
# Connect to the SQLite database (it will create a new one if it doesn't exist)
conn = sqlite3.connect('doctors.db')

# Replace 'table_name' with the name of the table you want to create in the database
table_name = 'Doctors'

# Use the `to_sql` method to save the DataFrame to the database
clean_df.to_sql(table_name, conn, if_exists='replace', index=False)

llm = llm_hf

db = SQLDatabase.from_uri("sqlite:///doctors.db")
db.get_table_names()
toolkit = SQLDatabaseToolkit(db=db,
llm=llm,
)
sql_executor = create_sql_agent(
llm=llm,
toolkit=toolkit,
verbose=True,
agent_type=AgentType.ZERO_SHOT_REACT_DESCRIPTION,
top_k = 10000,
#agent_executor_kwargs={"return_intermediate_steps": True},
)

from langchain.agents import initialize_agent, Tool
tools = [
Tool(
name="Doctors Database System",
func=sql_executor.run,
return_direct=True,
description="useful to give information about doctors names, specialities and locations. Input should be a fully formed question.",
)
]
from langchain.agents import ZeroShotAgent, Tool, AgentExecutor, ConversationalAgent
from langchain.memory import ConversationBufferWindowMemory
from langchain.llms import OpenAI
from langchain.chains import LLMChain

prefix = """You are a helpful assistant.
Have a normal conversation with a human.
You can offer to answer questions about a database with doctor information.
You have access to the following tools:"""
suffix = """Begin!"

{chat_history}
Question: {input}
{agent_scratchpad}"""

prompt = ConversationalAgent.create_prompt(
tools,
prefix=prefix,
suffix=suffix,
input_variables=["input", "chat_history", "agent_scratchpad"],
)
memory = ConversationBufferWindowMemory(memory_key="chat_history", k = 5)

llm_chain = LLMChain(llm=llm, prompt=prompt)

agent = ConversationalAgent(llm_chain=llm_chain,
#output_parser= lambda **kwargs : dict(kwargs),
verbose=True)

agent_chain = AgentExecutor.from_agent_and_tools(
agent=agent, tools=tools, verbose=True, memory=memory
)
agent_chain.run("Hello, good `
Буду очень признателен. Любое предложение, спасибо!

Подробнее здесь: https://stackoverflow.com/questions/771 ... r-notebook
Реклама
Ответить Пред. темаСлед. тема

Быстрый ответ

Изменение регистра текста: 
Смайлики
:) :( :oops: :roll: :wink: :muza: :clever: :sorry: :angel: :read: *x)
Ещё смайлики…
   
К этому ответу прикреплено по крайней мере одно вложение.

Если вы не хотите добавлять вложения, оставьте поля пустыми.

Максимально разрешённый размер вложения: 15 МБ.

  • Похожие темы
    Ответы
    Просмотры
    Последнее сообщение

Вернуться в «Python»