cigol123 commited on
Commit
b16e5ce
·
verified ·
1 Parent(s): d585858

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +15 -10
app.py CHANGED
@@ -11,12 +11,12 @@ llm = Llama(
11
  )
12
 
13
  def chat(message, history):
14
- # Enhanced system prompt for better responses
15
- system_prompt = "You are a helpful, knowledgeable, and professional AI assistant. Provide detailed and thoughtful responses."
16
 
17
  full_prompt = f"""SYSTEM: {system_prompt}
18
  USER: {message}
19
- ASSISTANT: Let me provide a comprehensive response.
20
  """
21
 
22
  response = llm(
@@ -26,19 +26,24 @@ ASSISTANT: Let me provide a comprehensive response.
26
  top_p=0.95,
27
  repeat_penalty=1.2,
28
  top_k=40,
29
- stop=["USER:", "\n\n"]
 
30
  )
31
 
32
- return response['choices'][0]['text']
 
 
 
 
33
 
34
  demo = gr.ChatInterface(
35
  fn=chat,
36
- title="YugoGPT Professional Assistant",
37
- description="I provide detailed and thoughtful responses to your questions.",
38
  examples=[
39
- "Explain quantum computing",
40
- "What are the main principles of machine learning?",
41
- "How does blockchain technology work?"
42
  ]
43
  )
44
 
 
11
  )
12
 
13
  def chat(message, history):
14
+ system_prompt = """Ti si YugoGPT, AI asistent koji prvenstveno komunicira na srpskom jeziku.
15
+ Tvoj zadatak je da daješ detaljne, istinite i korisne odgovore na srpskom jeziku."""
16
 
17
  full_prompt = f"""SYSTEM: {system_prompt}
18
  USER: {message}
19
+ ASSISTANT: Dozvolite mi da vam odgovorim na srpskom jeziku.
20
  """
21
 
22
  response = llm(
 
26
  top_p=0.95,
27
  repeat_penalty=1.2,
28
  top_k=40,
29
+ stop=["USER:", "\n\n"],
30
+ stream=True
31
  )
32
 
33
+ partial_message = ""
34
+ for chunk in response:
35
+ if chunk and chunk['choices'][0]['text']:
36
+ partial_message += chunk['choices'][0]['text']
37
+ yield partial_message
38
 
39
  demo = gr.ChatInterface(
40
  fn=chat,
41
+ title="YugoGPT Asistent",
42
+ description="Postavite pitanje na srpskom ili bilo kom jeziku bivše Jugoslavije.",
43
  examples=[
44
+ "Objasni kvantno računarstvo",
45
+ "Koje su glavne karakteristike veštačke inteligencije?",
46
+ "Kako funkcioniše blockchain tehnologija?"
47
  ]
48
  )
49