emeses commited on
Commit
133f56d
·
1 Parent(s): db9c707

Update space

Browse files
Files changed (1) hide show
  1. app.py +13 -11
app.py CHANGED
@@ -5,20 +5,22 @@ from huggingface_hub import InferenceClient
5
  client = InferenceClient("emeses/lab2_model")
6
 
7
  def respond(
8
- message,
9
- history: list[tuple[str, str]],
10
- system_message="You are a helpful assistant.",
11
- max_tokens=512,
12
- temperature=0.7,
13
- top_p=0.95,
14
- ):
15
- # Format conversation context
16
  conversation = system_message + "\n\n"
17
- for user_msg, assistant_msg in history:
18
- conversation += f"User: {user_msg}\nAssistant: {assistant_msg}\n"
 
 
19
  conversation += f"User: {message}\nAssistant: "
20
 
21
- # Stream response using text generation
22
  response = ""
23
  try:
24
  for token in client.text_generation(
 
5
  client = InferenceClient("emeses/lab2_model")
6
 
7
  def respond(
8
+ message: str,
9
+ history: List[Dict[str, str]],
10
+ system_message: str = "You are a helpful assistant.",
11
+ max_tokens: int = 512,
12
+ temperature: float = 0.7,
13
+ top_p: float = 0.95,
14
+ ) -> str:
15
+ # Format conversation using new messages format
16
  conversation = system_message + "\n\n"
17
+ for msg in history:
18
+ role = msg["role"]
19
+ content = msg["content"]
20
+ conversation += f"{role.capitalize()}: {content}\n"
21
  conversation += f"User: {message}\nAssistant: "
22
 
23
+ # Stream response
24
  response = ""
25
  try:
26
  for token in client.text_generation(