zakerytclarke commited on
Commit
d6c6437
·
verified ·
1 Parent(s): 00915d5

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +3 -6
app.py CHANGED
@@ -53,19 +53,17 @@ async def brave_search(query, count=1):
53
  print(f"Error: {response.status}, {await response.text()}")
54
  return []
55
 
56
-
57
  @traceable
58
  @log_time
59
- async def query_teapot(prompt, context, user_input):
60
  input_text = prompt + "\n" + context + "\n" + user_input
61
- print(input_text)
62
  start_time = time.time()
63
 
64
  inputs = tokenizer(input_text, return_tensors="pt")
65
  input_length = inputs["input_ids"].shape[1]
66
 
67
- # output = await asyncio.to_thread(model.generate, **inputs, max_new_tokens=512)
68
- output = model.generate(inputs, max_new_tokens=512)
69
 
70
  output_text = tokenizer.decode(output[0], skip_special_tokens=True)
71
  total_length = output.shape[1] # Includes both input and output tokens
@@ -78,7 +76,6 @@ async def query_teapot(prompt, context, user_input):
78
 
79
  return output_text
80
 
81
-
82
  @log_time
83
  async def handle_chat(user_input):
84
  search_start_time = time.time()
 
53
  print(f"Error: {response.status}, {await response.text()}")
54
  return []
55
 
 
56
  @traceable
57
  @log_time
58
+ def query_teapot(prompt, context, user_input):
59
  input_text = prompt + "\n" + context + "\n" + user_input
60
+
61
  start_time = time.time()
62
 
63
  inputs = tokenizer(input_text, return_tensors="pt")
64
  input_length = inputs["input_ids"].shape[1]
65
 
66
+ output = model.generate(**inputs, max_new_tokens=512)
 
67
 
68
  output_text = tokenizer.decode(output[0], skip_special_tokens=True)
69
  total_length = output.shape[1] # Includes both input and output tokens
 
76
 
77
  return output_text
78
 
 
79
  @log_time
80
  async def handle_chat(user_input):
81
  search_start_time = time.time()