cigol123 commited on
Commit
c4b24bf
·
verified ·
1 Parent(s): 6922353

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +17 -6
app.py CHANGED
@@ -10,11 +10,23 @@ llm = Llama(
10
  use_mmap=True
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 i korisne odgovore na srpskom jeziku."""
 
 
16
 
17
  full_prompt = f"""SYSTEM: {system_prompt}
 
 
 
 
18
  USER: {message}
19
  ASSISTANT: """
20
 
@@ -38,11 +50,11 @@ ASSISTANT: """
38
  demo = gr.ChatInterface(
39
  fn=chat,
40
  title="YugoGPT Asistent",
41
- description="Postavite pitanje na srpskom ili bilo kom jeziku bivše Jugoslavije.",
42
  examples=[
43
- "Objasni kvantno računarstvo",
44
- "Koje su glavne karakteristike veštačke inteligencije?",
45
- "Kako funkcioniše blockchain tehnologija?"
46
  ]
47
  )
48
 
@@ -53,4 +65,3 @@ if __name__ == "__main__":
53
  share=False
54
  )
55
 
56
-
 
10
  use_mmap=True
11
  )
12
 
13
+ def format_chat_history(history):
14
+ formatted_history = ""
15
+ for user_msg, assistant_msg in history:
16
+ formatted_history += f"USER: {user_msg}\nASSISTANT: {assistant_msg}\n"
17
+ return formatted_history
18
+
19
  def chat(message, history):
20
  system_prompt = """Ti si YugoGPT, AI asistent koji prvenstveno komunicira na srpskom jeziku.
21
+ Tvoj zadatak je da daješ detaljne i korisne odgovore na srpskom jeziku, uzimajući u obzir prethodnu konverzaciju."""
22
+
23
+ chat_history = format_chat_history(history)
24
 
25
  full_prompt = f"""SYSTEM: {system_prompt}
26
+
27
+ PRETHODNA KONVERZACIJA:
28
+ {chat_history}
29
+
30
  USER: {message}
31
  ASSISTANT: """
32
 
 
50
  demo = gr.ChatInterface(
51
  fn=chat,
52
  title="YugoGPT Asistent",
53
+ description="Vodite smislenu konverzaciju sa AI asistentom na srpskom jeziku.",
54
  examples=[
55
+ "Kako si danas?",
56
+ "Šta misliš o veštačkoj inteligenciji?",
57
+ "Objasni mi blockchain tehnologiju"
58
  ]
59
  )
60
 
 
65
  share=False
66
  )
67