diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 000000000..b242572ef --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,5 @@ +{ + "githubPullRequests.ignoredPullRequestBranches": [ + "main" + ] +} \ No newline at end of file diff --git a/Chatbot.py b/Chatbot.py index 0a4f2df45..3b8200580 100644 --- a/Chatbot.py +++ b/Chatbot.py @@ -1,29 +1,34 @@ -from openai import OpenAI +from langchain.chains import ConversationalRetrievalChain +from langchain.chains.llm import LLMChain +from langchain.schema import Document +from langchain_community.llms import Ollama + import streamlit as st with st.sidebar: - openai_api_key = st.text_input("OpenAI API Key", key="chatbot_api_key", type="password") - "[Get an OpenAI API key](https://platform.openai.com/account/api-keys)" - "[View the source code](https://github.com/streamlit/llm-examples/blob/main/Chatbot.py)" - "[![Open in GitHub Codespaces](https://github.com/codespaces/badge.svg)](https://codespaces.new/streamlit/llm-examples?quickstart=1)" + st.text_input("choose version") + +# openai_api_key = st.text_input("OpenAI API Key", key="chatbot_api_key", type="password") +# "[Get an OpenAI API key](https://platform.openai.com/account/api-keys)" +# "[View the source code](https://github.com/streamlit/llm-examples/blob/main/Chatbot.py)" +# "[![Open in GitHub Codespaces](https://github.com/codespaces/badge.svg)](https://codespaces.new/streamlit/llm-examples?quickstart=1)" -st.title("πŸ’¬ Chatbot") -st.caption("πŸš€ A Streamlit chatbot powered by OpenAI") +st.title("πŸ’¬ AIA Chatbot") +st.caption("πŸš€ AIA θͺ²η¨‹ζŸ₯θ©’ζ©Ÿε™¨δΊΊ") if "messages" not in st.session_state: st.session_state["messages"] = [{"role": "assistant", "content": "How can I help you?"}] for msg in st.session_state.messages: st.chat_message(msg["role"]).write(msg["content"]) +llm = Ollama(model="llama3", base_url="http://3ece-140-109-17-42.ngrok-free.app") + if prompt := st.chat_input(): - if not openai_api_key: - st.info("Please add your OpenAI API key to continue.") - st.stop() - client = OpenAI(api_key=openai_api_key) st.session_state.messages.append({"role": "user", "content": prompt}) st.chat_message("user").write(prompt) - response = client.chat.completions.create(model="gpt-3.5-turbo", messages=st.session_state.messages) - msg = response.choices[0].message.content + response = llm.invoke(st.session_state.messages) + #msg = response.choices[0].message.content + msg = response st.session_state.messages.append({"role": "assistant", "content": msg}) st.chat_message("assistant").write(msg)