Skip to content

Commit

Permalink
✨ Add startup generator feature
Browse files Browse the repository at this point in the history
  • Loading branch information
shroominic committed Nov 10, 2023
1 parent 45f52a4 commit a6afc12
Showing 1 changed file with 25 additions and 13 deletions.
38 changes: 25 additions & 13 deletions examples/async.py
Original file line number Diff line number Diff line change
@@ -1,23 +1,35 @@
from funcchain import chain
import asyncio
from funcchain import achain, settings
from langchain.pydantic_v1 import BaseModel

settings.MODEL_TEMPERATURE = 1

def random_city() -> str:
"""
Tell me a random city, i need this for a game.
"""
return chain()

class StartupConcept(BaseModel):
name: str
description: str


async def random_city_async() -> str:
async def startup_generator(topic: str) -> StartupConcept:
"""
Tell me a random city, i need this for a game.
Generate a random startup for the given topic.
"""
return await chain()
return await achain()


if __name__ == "__main__":
print(random_city())
async def generate_random_startups(topic: str, amount: int = 3) -> list[StartupConcept]:
return await asyncio.gather(
*[
startup_generator(topic)
for _ in range(amount)
]
)

from asyncio import run
if __name__ == "__main__":
topic = "AI generated Vegan Recipes"

startups = asyncio.run(generate_random_startups(topic))

print(run(random_city_async()))
for startup in startups:
print("name:", startup.name)
print("concept:", startup.description)

0 comments on commit a6afc12

Please sign in to comment.