Skip to content

Access 'configurable' field values in a prompt within a conversation QA chain #638

Answered by pmosconi
Chengdyc asked this question in Q&A
Discussion options

You must be logged in to vote

Hi @Chengdyc ,
after a few hours of head scratching and trial and error, I've been able to make it.
I'm not using a configurable field, but a prompt variable that is assigned in the chain's first step reading from config.

Here's some code:

import os
from typing import Any, Dict
from fastapi import Request
from langchain_openai import AzureChatOpenAI
from langchain_core.prompts import ChatPromptTemplate, MessagesPlaceholder
from langchain_core.runnables import RunnablePassthrough

# Pass the chat history keeping the list of messages structure
def history_pass(x: list) -> list:
    lst = []
    for i in x:
        lst.append(i)
    return lst

# Get the user ID from the runnable config
def …

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Answer selected by Chengdyc
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants