OneShotSolver.predict:v6
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
import weave
from utils import Problem
import logging
from pydantic.main import BaseModel
from pydantic.fields import Field
class Solution(BaseModel):
core_question: str = Field(..., description="Core question of the problem")
problem_solving_info: str = Field(..., description="Problem-solving information related to the core question")
plan: str = Field(..., description="Step by step plan to solve the problem")
pseudocode: str = Field(..., description="Pseudocode to solve the problem")
source_code: str = Field(..., description="Valid Python3 sourcecode to solve the problem.")
@weave.op
async def one_shot_solver(
problem: Problem,
llm_model: str,
system_prompt: str,
prompt_template: str,
# temperature: float = 0.7,
timeout: int = 10
) -> str:
logging.info(f"Solving problem: {problem.problem_name}")
# call model one first time to get the code
logging.info("Calling model to solve the problem")