langchain-production-project's People
Forkers
inayet truestone jan-karsten-kuhnke kimiyo flavorfan flaginwind phoenixml lukasfragas jon-chun jlcan themiguelamador sundog-ftw mikeborman1 renjithvsampcome nataliakzm hx-natthawat kishorkukreja ejiro saurabharch hercules261188 jaredkirby borislav-1 mvandermeulen jim2mul mbastar emehprincewill wassay13 dzakwanf 19950606 lucky-rathore sathish0911 darkmtrance jogster tobias-hui vcutilla obitracks blokuspokus saltedfishlz nchakik cdaprod keshavaspanda rishumehrotra hunter5thompson 3dln bk2k3bk rakeshrau geekaz01d geraldsanga jraj002 mdwoicke luyi1678 chellish-webadmin ritesh1991 nikita1503 sizzles shahriar6740 mthamil107 calicanx babatunde-fatai hzmarrou jarekmor nahin-sajjad leoberti austilphukir stephanfoerster2langchain-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
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google โค๏ธ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.