andreska commited on
Commit
82909b4
·
verified ·
1 Parent(s): 2fc80c5

Removed chunks, as it didn't work anyway

Browse files
Files changed (1) hide show
  1. app.py +14 -26
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
- responses = []
30
-
31
- for chunk in chunk_text(context, max_chunk_length):
32
- messages = [
33
- {"role": "system", "content": f"Context: {context}"},
34
- {"role": "user","content": user_input}
35
- ]
36
-
37
- completion = client.chat.completions.create(
38
- model= "Qwen/Qwen2.5-72B-Instruct",
39
- #model="Qwen/Qwen2.5-Coder-32B-Instruct",
40
- #model="HuggingFaceTB/SmolLM2-1.7B-Instruct",
41
- messages=messages,
42
- max_tokens=500
43
- )
44
-
45
- answer = completion.choices[0].message['content']
46
- responses.append(answer)
47
 
48
- final_response = " ".join(responses)
49
- st.write(f"Adrega AI: {final_response}")
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.")