Инструментарий с помощью Langchain Bedrock для создания RAG AI-ChatPython

Программы на Python
Ответить Пред. темаСлед. тема
Anonymous
 Инструментарий с помощью Langchain Bedrock для создания RAG AI-Chat

Сообщение Anonymous »

У меня есть функция, которая принимает модель языка, хранилище векторов, вопросы и инструменты; и возвращает ответ, в данный момент аргумент инструментов не добавляется, поскольку в этом примере функция .bind_tools не является атрибутом llm -> llm находится ниже

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

## Bedrock Client
bedrock_client = boto3.client(service_name="bedrock-runtime", region_name="us-west-2")
bedrock_embeddings = BedrockEmbeddings(model_id="amazon.titan-embed-text-v1", client=bedrock_client)

llm=Bedrock(model_id="anthropic.claude-v2:1", client=bedrock_client,
model_kwargs={'max_tokens_to_sample': 512})
без изменения LLM на ChatOpenAPI, как в примере ссылки, как привязать инструмент к основе langchain.
Я также сделал это пробовал инструменты рендеринга, но не работают. Ниже моя основная функция получения ответа

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

def get_response(llm, vectorstore, question, tools ):

## create prompt / template this helps to guide the AI on what to look out for and how to answer
prompt_template = """

System: You are a helpful ai bot, your name is Alex, you are to provide information to humans based on faq and user information, in the user information provided you are to extract the users' firstName and lastName from the json payload and recognize that as the persons name. use the currencyVerificationData to determine the number of currency accounts that the user has and if they are approved if the status is VALID, other statuses will indicate that the user is not yet approved and needs to provide more information for validation. use bankFilledData as the users beneficiaries, from that section of the payload you would be able to extract the beneficiaries bankName, bankAccountNumber; use accountDetails as information for bank account detail information;

Human: Please use the given context to provide concise answer to the question
If you don't know the answer, just say that you don't know, don't try to make up an answer.
If you need clarity, ask more questions, do not refer to the json payload when answering questions just use the values you retrieve from the payload to answer

{context}


The way you use the information is to identify users name and use it in response

Question: {question}

Assistant:"""

# llm.bind_tools(tools) // not working, python error attribute not found

PROMPT = PromptTemplate(
template=prompt_template, input_variables=["context", "question", "user_information"]
)

qa = RetrievalQA.from_chain_type(
llm=llm,
chain_type="stuff",
retriever=vectorstore.as_retriever(
search_type="similarity", search_kwargs={"k": 5}
),
return_source_documents=True,
chain_type_kwargs={"prompt": PROMPT}
)
answer=qa({"query":question})
return answer['result']
Наконец, я хочу добиться просто способа вызова функций на основе ввода указанного пользователя

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

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

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

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

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

  • Похожие темы
    Ответы
    Просмотры
    Последнее сообщение
  • API Google Chat: как получить событие Календаря Google или ресурс задачи Google из Chat space.messages.list?
    Anonymous » » в форуме JAVA
    0 Ответы
    29 Просмотры
    Последнее сообщение Anonymous
  • Как я могу улучшить время отклика цепочки RAG, разработанной с помощью Ollama, langchain и pgvector?
    Anonymous » » в форуме Python
    0 Ответы
    31 Просмотры
    Последнее сообщение Anonymous
  • Как добавить историю чата в RAG с помощью langchain
    Anonymous » » в форуме Python
    0 Ответы
    15 Просмотры
    Последнее сообщение Anonymous
  • Langchain RAG с историей и цитатами
    Anonymous » » в форуме Python
    0 Ответы
    10 Просмотры
    Последнее сообщение Anonymous
  • Получение метаданных об использовании токенов из вызовов Gemini LLM в LangChain RAG RunnableSequence
    Anonymous » » в форуме Python
    0 Ответы
    29 Просмотры
    Последнее сообщение Anonymous

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