Spaces:
Runtime error
Runtime error
update model
Browse files- app.py +1 -1
- planet_model.py +41 -13
app.py
CHANGED
|
@@ -36,7 +36,7 @@ async def onClick(vacationType,familyType,duration,purpose,interests):
|
|
| 36 |
"Visual Arts: Imagery from H.R. Giger (Alien) or Moebius (The Incal).",
|
| 37 |
"Graphic Novels: Saga, Transmetropolitan."
|
| 38 |
),
|
| 39 |
-
|
| 40 |
)
|
| 41 |
result_1 = agent.run_sync(user_prompt="for space travel which planet is the best")
|
| 42 |
result = result_1
|
|
|
|
| 36 |
"Visual Arts: Imagery from H.R. Giger (Alien) or Moebius (The Incal).",
|
| 37 |
"Graphic Novels: Saga, Transmetropolitan."
|
| 38 |
),
|
| 39 |
+
result_type = customModel.TravelAgency
|
| 40 |
)
|
| 41 |
result_1 = agent.run_sync(user_prompt="for space travel which planet is the best")
|
| 42 |
result = result_1
|
planet_model.py
CHANGED
|
@@ -1,16 +1,44 @@
|
|
| 1 |
from pydantic import BaseModel
|
| 2 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 3 |
class Planet(BaseModel):
|
| 4 |
-
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
from pydantic import BaseModel
|
| 2 |
|
| 3 |
+
from dataclasses import dataclass, field
|
| 4 |
+
from typing import List, Dict
|
| 5 |
+
|
| 6 |
+
@dataclass
|
| 7 |
class Planet(BaseModel):
|
| 8 |
+
name: str
|
| 9 |
+
description: str
|
| 10 |
+
accommodation: str
|
| 11 |
+
activities: List[str]
|
| 12 |
+
photography: str
|
| 13 |
+
|
| 14 |
+
@dataclass
|
| 15 |
+
class Category(BaseModel):
|
| 16 |
+
budget_range: str
|
| 17 |
+
planets: List[Planet] = field(default_factory=list)
|
| 18 |
+
|
| 19 |
+
@dataclass
|
| 20 |
+
class TravelAgency(BaseModel):
|
| 21 |
+
name: str
|
| 22 |
+
categories: Dict[str, Category] = field(default_factory=dict)
|
| 23 |
+
|
| 24 |
+
def add_planet(self, category_name: str, budget_range: str, planet: Planet):
|
| 25 |
+
# Ensure category exists, create if not
|
| 26 |
+
if category_name not in self.categories:
|
| 27 |
+
self.categories[category_name] = Category(budget_range=budget_range)
|
| 28 |
+
self.categories[category_name].planets.append(planet)
|
| 29 |
+
|
| 30 |
+
|
| 31 |
+
# class Planet(BaseModel):
|
| 32 |
+
# def __init__(self, name, atmosphere, species, signature_dish, activities):
|
| 33 |
+
# self.name = name
|
| 34 |
+
# self.atmosphere = atmosphere
|
| 35 |
+
# self.species = species
|
| 36 |
+
# self.signature_dish = signature_dish
|
| 37 |
+
# self.activities = activities
|
| 38 |
+
|
| 39 |
+
# def describe(self):
|
| 40 |
+
# return f"Planet: {self.name}\n" \
|
| 41 |
+
# f"Atmosphere: {self.atmosphere}\n" \
|
| 42 |
+
# f"Species: {self.species}\n" \
|
| 43 |
+
# f"Signature Dish: {self.signature_dish}\n" \
|
| 44 |
+
# f"Activities: {', '.join(self.activities)}"
|