moriire commited on
Commit
f88f764
1 Parent(s): ef6577b

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +11 -8
app.py CHANGED
@@ -5,6 +5,7 @@ from time import time
5
  import logging
6
  import llama_cpp
7
  import llama_cpp.llama_tokenizer
 
8
 
9
  llama = llama_cpp.Llama.from_pretrained(
10
  repo_id="Qwen/Qwen1.5-0.5B-Chat-GGUF",
@@ -57,23 +58,25 @@ def health():
57
  return {"status": "ok"}
58
 
59
 
 
 
 
 
 
 
60
  # Chat Completion API
61
  @app.get("/generate_stream")
62
- async def complete(
63
- question: str,
64
- system: str = "You are a story writing assistant.",
65
- temperature: float = 0.7,
66
- seed: int = 42,
67
  ) -> dict:
68
  try:
69
  st = time()
70
  output = llama.create_chat_completion(
71
  messages=[
72
  {"role": "system", "content": system},
73
- {"role": "user", "content": question},
74
  ],
75
- temperature=temperature,
76
- seed=seed,
77
  #stream=True
78
  )
79
  """
 
5
  import logging
6
  import llama_cpp
7
  import llama_cpp.llama_tokenizer
8
+ from pydantic import BaseModel
9
 
10
  llama = llama_cpp.Llama.from_pretrained(
11
  repo_id="Qwen/Qwen1.5-0.5B-Chat-GGUF",
 
58
  return {"status": "ok"}
59
 
60
 
61
+ class GenModel(BaseModel):
62
+ question: str
63
+ system: str = "You are a story writing assistant."
64
+ temperature: float = 0.7
65
+ seed: int = 42
66
+
67
  # Chat Completion API
68
  @app.get("/generate_stream")
69
+ async def complete(gen:GenModel
 
 
 
 
70
  ) -> dict:
71
  try:
72
  st = time()
73
  output = llama.create_chat_completion(
74
  messages=[
75
  {"role": "system", "content": system},
76
+ {"role": "user", "content": gen['question']},
77
  ],
78
+ temperature=gen['temperature'],
79
+ seed=gen['seed'],
80
  #stream=True
81
  )
82
  """