Spaces:
Sleeping
Sleeping
Leonardo Parente
commited on
Commit
·
045b4fe
1
Parent(s):
8d4146f
use together
Browse files
app.py
CHANGED
@@ -1,13 +1,12 @@
|
|
1 |
import base64
|
2 |
from pathlib import Path
|
3 |
import streamlit as st
|
4 |
-
from transformers import AutoModelForCausalLM, AutoTokenizer, pipeline
|
5 |
from langchain.memory import ConversationBufferMemory
|
6 |
from langchain.memory.chat_message_histories import StreamlitChatMessageHistory
|
7 |
from langchain.chains import ConversationalRetrievalChain
|
8 |
from langchain.embeddings import VoyageEmbeddings
|
9 |
-
from langchain.vectorstores import SupabaseVectorStore
|
10 |
-
from langchain.llms.
|
11 |
from st_supabase_connection import SupabaseConnection
|
12 |
|
13 |
msgs = StreamlitChatMessageHistory()
|
@@ -35,32 +34,16 @@ def load_retriever():
|
|
35 |
return vector_store.as_retriever()
|
36 |
|
37 |
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
offload_state_dict=True,
|
46 |
-
torch_dtype="auto",
|
47 |
-
).eval()
|
48 |
-
pipe = pipeline(
|
49 |
-
"text-generation",
|
50 |
-
model=model,
|
51 |
-
tokenizer=tokenizer,
|
52 |
-
max_new_tokens=500,
|
53 |
-
eos_token_id=tokenizer.eos_token_id,
|
54 |
-
pad_token_id=tokenizer.eos_token_id,
|
55 |
-
do_sample=True,
|
56 |
-
temperature=0.3,
|
57 |
-
)
|
58 |
-
return HuggingFacePipeline(pipeline=pipe)
|
59 |
-
|
60 |
|
61 |
-
hf = load_model()
|
62 |
retriever = load_retriever()
|
63 |
-
chat = ConversationalRetrievalChain.from_llm(
|
64 |
|
65 |
st.markdown(
|
66 |
"<div style='display: flex;justify-content: center;'><img width='150' src='data:image/png;base64,{}' class='img-fluid'></div>".format(
|
|
|
1 |
import base64
|
2 |
from pathlib import Path
|
3 |
import streamlit as st
|
|
|
4 |
from langchain.memory import ConversationBufferMemory
|
5 |
from langchain.memory.chat_message_histories import StreamlitChatMessageHistory
|
6 |
from langchain.chains import ConversationalRetrievalChain
|
7 |
from langchain.embeddings import VoyageEmbeddings
|
8 |
+
from langchain.vectorstores.supabase import SupabaseVectorStore
|
9 |
+
from langchain.llms.together import Together
|
10 |
from st_supabase_connection import SupabaseConnection
|
11 |
|
12 |
msgs = StreamlitChatMessageHistory()
|
|
|
34 |
return vector_store.as_retriever()
|
35 |
|
36 |
|
37 |
+
llm = Together(
|
38 |
+
model="togethercomputer/StripedHyena-Nous-7B",
|
39 |
+
temperature=0.5,
|
40 |
+
max_tokens=200,
|
41 |
+
top_k=1,
|
42 |
+
together_api_key=st.secrets.together_api_key,
|
43 |
+
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
44 |
|
|
|
45 |
retriever = load_retriever()
|
46 |
+
chat = ConversationalRetrievalChain.from_llm(llm, retriever)
|
47 |
|
48 |
st.markdown(
|
49 |
"<div style='display: flex;justify-content: center;'><img width='150' src='data:image/png;base64,{}' class='img-fluid'></div>".format(
|