Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update README.md (fix repo url), fix typo, add custom prompt #24

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ To set up and run this project, follow these steps:
1. Clone the repository and navigate to the project directory:

```bash
git clone https://github.com/peterw/Chat-with-Git-Repo.git
cd Chat-with-Git-Repo
git clone https://github.com/peterw/Chat-with-Github-Repo.git
cd Chat-with-Github-Repo
```

2. Install the required packages with `pip`:
Expand Down
15 changes: 13 additions & 2 deletions src/utils/chat.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def run_chat_app(activeloop_dataset_path):

# Initialize the session state for generated responses and past inputs
if "generated" not in st.session_state:
st.session_state["generated"] = ["i am ready to help you ser"]
st.session_state["generated"] = ["i am ready to help you sir"]

if "past" not in st.session_state:
st.session_state["past"] = ["hello"]
Expand Down Expand Up @@ -67,6 +67,16 @@ def get_text():
input_text = st.text_input("", key="input")
return input_text

def get_prompt():
prompt_template = """Use the following pieces of context to answer the question at the end.
If you don't know the answer, just say that you don't know, don't try to make up an answer.
If the question isn't about the context, just say that your purpose is to provide information about the Repo.

{context}

Question: {question}
"""
return PromptTemplate(template=prompt_template, input_variables=["context", "question"])

def search_db(db, query):
"""Search for a response to the query in the DeepLake database."""
Expand All @@ -80,7 +90,8 @@ def search_db(db, query):
# Create a ChatOpenAI model instance
model = ChatOpenAI(model="gpt-3.5-turbo")
# Create a RetrievalQA instance from the model and retriever
qa = RetrievalQA.from_llm(model, retriever=retriever)
chain_type_kwargs = {"prompt": get_prompt()}
qa = RetrievalQA.from_chain_type(model, retriever=retriever, chain_type_kwargs=chain_type_kwargs)
# Return the result of the query
return qa.run(query)

Expand Down