Spaces:
Sleeping
Sleeping
Removed chunks, as it didn't work anyway
Browse files
app.py
CHANGED
|
@@ -13,39 +13,27 @@ def read_dataset(dataset):
|
|
| 13 |
text.append(item['text'])
|
| 14 |
return "\n".join(text)
|
| 15 |
|
| 16 |
-
def chunk_text(text, max_length):
|
| 17 |
-
words = text.split()
|
| 18 |
-
for i in range(0, len(words), max_length):
|
| 19 |
-
yield " ".join(words[i:i+ max_length])
|
| 20 |
-
|
| 21 |
context = read_dataset(dataset)
|
| 22 |
|
| 23 |
-
max_chunk_length = 30000;
|
| 24 |
st.title("Adrega AI Help")
|
| 25 |
user_input = st.text_input('Ask me a question')
|
| 26 |
|
| 27 |
if st.button("Submit"):
|
| 28 |
if user_input:
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
|
| 35 |
-
|
| 36 |
-
|
| 37 |
-
|
| 38 |
-
|
| 39 |
-
|
| 40 |
-
|
| 41 |
-
messages=messages,
|
| 42 |
-
max_tokens=500
|
| 43 |
-
)
|
| 44 |
-
|
| 45 |
-
answer = completion.choices[0].message['content']
|
| 46 |
-
responses.append(answer)
|
| 47 |
|
| 48 |
-
|
| 49 |
-
st.write(f"Adrega AI: {
|
| 50 |
else:
|
| 51 |
st.write("Please enter a question.")
|
|
|
|
| 13 |
text.append(item['text'])
|
| 14 |
return "\n".join(text)
|
| 15 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 16 |
context = read_dataset(dataset)
|
| 17 |
|
|
|
|
| 18 |
st.title("Adrega AI Help")
|
| 19 |
user_input = st.text_input('Ask me a question')
|
| 20 |
|
| 21 |
if st.button("Submit"):
|
| 22 |
if user_input:
|
| 23 |
+
messages = [
|
| 24 |
+
{"role": "system", "content": f"Context: {context}"},
|
| 25 |
+
{"role": "user","content": user_input}
|
| 26 |
+
]
|
| 27 |
+
|
| 28 |
+
completion = client.chat.completions.create(
|
| 29 |
+
model= "Qwen/Qwen2.5-72B-Instruct",
|
| 30 |
+
#model="Qwen/Qwen2.5-Coder-32B-Instruct",
|
| 31 |
+
#model="HuggingFaceTB/SmolLM2-1.7B-Instruct",
|
| 32 |
+
messages=messages,
|
| 33 |
+
max_tokens=500
|
| 34 |
+
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 35 |
|
| 36 |
+
answer = completion.choices[0].message['content']
|
| 37 |
+
st.write(f"Adrega AI: {answer}")
|
| 38 |
else:
|
| 39 |
st.write("Please enter a question.")
|