import edgedb
import edgedb.ai
c = edgedb.create_client()
gpt4ai = edgedb.ai.create_AI(c, model="gpt-4-turbo-preview")
blog_ai = gpt4ai.with_context(query="select BlogPost")
print(blog_ai.query_rag("what's that?"))
# or use event-stream:
for data in blog_ai.stream_rag("what's that?"):
print(data)
Async client:
import asyncio
import edgedb
import edgedb.ai
c = edgedb.create_async_client()
async def main():
gpt4ai = await edgedb.ai.create_async_AI(c, model="gpt-4-turbo-preview")
blog_ai = gpt4ai.with_context(query="select BlogPost")
print(await blog_ai.query_rag("what's that?"))
# or use event-stream:
async for data in blog_ai.stream_rag("what's that?"):
print(data)
asyncio.run(main())
Blocking client:
Async client: