Livoa LogoLivoa
Phase 1: Planning Generation
Phase 2: Code Implementation
Task: "Create function to fetch weather from OpenWeatherMap API"

LLM Planning Phase

Prompt: Analyze requirements

Output: Generate step-by-step plan

Generated Plan:

1. Setup authentication (API key)

2. Construct request parameters (city, units)

3. Make HTTP GET request

4. Handle errors (timeout, invalid response)

5. Parse and return weather data

Input: Original Task + Generated Plan

(Both provided to implementation phase)

LLM Implementation Phase

Prompt: Follow the plan step-by-step

Output: Generate complete code

Generated Python Code:

def get_weather(city, api_key):

# Step 1: Setup authentication

headers = {'Authorization': f'Bearer {api_key}'}

# Step 2: Construct parameters

params = {'q': city, 'units': 'metric'}

# Step 3: Make request

try:

response = requests.get(URL, params=params, headers=headers, timeout=10)

response.raise_for_status()

# Step 4: Error handling (implicit in try-except)

return response.json()

except requests.RequestException as e:

raise APIError(f'Failed: {e}')

Plan passed to Phase 2 →

dia 2

by rukhma

0
0 uses