Giter Site home page Giter Site logo

langchain-production-project's People

Contributors

coding-crashkurse avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

langchain-production-project's Issues

Service3/app.py Edits

Hey pretty cool work.

I reckon format_docs function in service3/app.py might need a bit of change. It just takes in the source of docs and no page content leading to model making hallucinating. So adding doc.page_content should solve it.

Cheers

History for RetrievalQA

Hi, I was trying this setup for RetrievalQA but I'm unable to fetch history for the same. This is how I have updated the service 3. I have utilized deeplake local vector db for the same.
requirements
langchain==0.0.201 openai==0.27.8 unstructured==0.7.5 deeplake==3.6.4 tiktoken==0.4.0 python-dotenv

@app.post("/service3/{conversation_id}")
async def service3(conversation_id: str, conversation: Conversation):
print('Inside service3')
print(conversation)
query = conversation.conversation[-1].content

deeplake_outdir = "./VectorDB/IQA-v2-2docs/"

texts = pdf_loder()
add_data_vector_db(texts, deeplake_outdir)
dl_db = read_vector_db(deeplake_outdir)
retriever = dl_db.as_retriever()
prompt_template = """ Following is a legal statement of work (SOW) for a contract. You are an intelligent AI which analyses contract snippets and answers the questions. If you don't know the answer, just say that you don't know, don't try to make up an answer. 
{context}
Question: {question} 
Answer:
"""
PROMPT = PromptTemplate(template=prompt_template, input_variables=["context", "question"] ) 

chain_type_kwargs = {"prompt": PROMPT}
model = AzureChatOpenAI(
    # model_name = "gpt-4",
    model_name = "gpt-3.5-turbo",
    openai_api_base=os.environ['OPENAI_API_BASE'],
    openai_api_version=os.environ['OPENAI_API_VERSION'],
    deployment_name="",
    openai_api_key=os.environ["OPENAI_API_KEY"],
    openai_api_type = "azure",
)
qa = RetrievalQA.from_chain_type(llm = model, chain_type='stuff', retriever=retriever, chain_type_kwargs=chain_type_kwargs,return_source_documents=True)

response = qa({"query": query}, return_only_outputs=True)
return {"id": conversation_id, "reply": response['result']}`

When I ask 2-3 questions to this and I ask let's say what was my first question the model is returning the complete context and not the history. Also, in my redis I can see the Human and Assitant content getting stored. Any help would be appreciated around working this for RetrievalQA.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.