The ask
function is designed for seamless interaction with the AI chat named Cloude using Asynchronous
.
Properties:
prompt
: Your query or message sent to the AI.
history
: The conversation history, which must be an object of type AsyncHistory
.
Example Usage:
from litegpt import AsyncLiteGPT
import asyncio
async def main():
bot = AsyncLiteGPT(http2=True)
print(await bot.ask("Your query text..."))
asyncio.run(main())
from litegpt import AsyncLiteGPT
from litegpt.lib import AsyncHistory
import asyncio
# Creating a Asynchronous history object and adding messages
async def main():
history = AsyncHistory()
await history.insert([
("system", "system options here!"),
("assistant", "assistant first message!"),
("user", "user message here!"),
("assistant", "assistant second message!")
])
# Initializing the LiteGPT object and sending a request
bot = LiteGPT(http2=True)
print(await bot.ask("Your query text...", history))
asyncio.run(main())
Thus, the ask
function provides a convenient and efficient way to send queries to the AI chat while maintaining the dialogue context.
Last updated