Do0rMaMu commited on
Commit
7bb2e96
1 Parent(s): 465d646

Update main.py

Browse files
Files changed (1) hide show
  1. main.py +9 -18
main.py CHANGED
@@ -13,13 +13,13 @@ llm = Llama(
13
 
14
  # Pydantic object for validation
15
  class Validation(BaseModel):
16
- user_prompt: str # User's input prompt
17
- system_prompt: str # System's guiding prompt
18
- max_tokens: int = 1024,
19
- temperature: float = 0.01,
20
- top_p: float = 0.9,
21
- repeat_penalty: float = 1.1,
22
- top_k: int = 40
23
 
24
  # FastAPI application initialization
25
  app = FastAPI()
@@ -33,16 +33,7 @@ async def generate_response(item: Validation):
33
  { item.user_prompt }<|eot_id|> \n <|start_header_id|>assistant<|end_header_id|>"""
34
 
35
  # Call the Llama model to generate a response
36
- max_tokens = int(item.max_tokens)
37
- temperature = float(item.temperature)
38
- top_p = float(item.top_p)
39
- repeat_penalty = float(item.repeat_penalty) # Explicitly cast to float
40
- top_k = int(item.top_k)
41
-
42
- # Call the Llama model to generate a response
43
- output = llm(prompt, max_tokens=max_tokens, temperature=temperature, top_p=top_p,
44
- repeat_penalty=repeat_penalty, top_k=top_k, echo=True)
45
-
46
 
47
  # Extract and return the text from the response
48
- return output['choices'][0]['text']
 
13
 
14
  # Pydantic object for validation
15
  class Validation(BaseModel):
16
+ user_prompt: str
17
+ system_prompt: str
18
+ max_tokens = 1024
19
+ temperature = 0.001
20
+ top_p = 0.9
21
+ repeat_penalty = 1.1
22
+ top_k = 40
23
 
24
  # FastAPI application initialization
25
  app = FastAPI()
 
33
  { item.user_prompt }<|eot_id|> \n <|start_header_id|>assistant<|end_header_id|>"""
34
 
35
  # Call the Llama model to generate a response
36
+ output = llm(prompt, max_tokens = item.max_tokens,temperature = item.temperature , top_p = item.top_p , repeat_penalty = item.repeat_penalty, top_k = item.top_k ,echo=True) # Update parameters as needed
 
 
 
 
 
 
 
 
 
37
 
38
  # Extract and return the text from the response
39
+ return output['choices'][0]['text']