diff --git a/README.md b/README.md index 8b58996..6b8f302 100644 --- a/README.md +++ b/README.md @@ -2,6 +2,8 @@ [![Run Tests](https://github.com/slava-vishnyakov/chatlet/actions/workflows/run-tests.yml/badge.svg)](https://github.com/slava-vishnyakov/chatlet/actions/workflows/run-tests.yml) +![Chatlet Demo](docs/img.png) + Chatlet is a Python wrapper for the OpenRouter API, providing an easy-to-use interface for interacting with various AI models. Inspired by [Claudette](https://claudette.answer.ai/), which supports only Anthropic Claude. @@ -213,8 +215,10 @@ print(response) ### Using Tools ```python -def get_weather(location: str, unit: str = "celsius") -> dict: - """Get the current weather in a given location.""" +def get_weather( + location: str, # The location to get the weather for. + unit: str = "celsius" # The unit to return the temperature in. + ) -> dict: # Get the current weather in a given location. return {"temperature": 22, "unit": unit, "condition": "Sunny"} chat = Chatlet() diff --git a/docs/img.png b/docs/img.png new file mode 100644 index 0000000..cd2856f Binary files /dev/null and b/docs/img.png differ diff --git a/docs/index.html b/docs/index.html new file mode 100644 index 0000000..099177a --- /dev/null +++ b/docs/index.html @@ -0,0 +1,361 @@ + + + +
+ + +from chatlet import Chatlet
+
+chat = Chatlet(api_key="Your-OpenRouter-API-key")
+chat("Hello, how are you?")
+
+chat("Who are you?")
+
+
+chat("What is Chatlet?")
+
+
+chat("What can Chatlet do?")
+
+ These features make Chatlet a versatile and powerful tool for interacting with AI models through the OpenRouter API.
+
+chat("Can it use tools?")
+
+ def get_weather(
+ location: str, # The location to get the weather for
+ unit: str = "celsius" # The unit to return the temperature in
+ ) -> dict: # Get the current weather in a given location
+ return {"temperature": 22, "unit": unit, "condition": "Sunny"}
+
+# Note: All comments are passed to the model via docments
+
+chat = Chatlet()
+response = chat("What's the weather like in New York City?",
+ tools=[get_weather])
+
+ print(chat.tool_called)
+ print(chat.tool_args)
+ print(chat.tool_result)
+ chat("Summarize")
+
+chat("Can I add URLs to my request for additional context?")
+
+ chat("Summarize the article I provided",
+ urls=["https://example.com/article"
+])
+
+chat("That's cool! Can Chatlet handle images?")
+
+ chat("What's in this image?", images=["cat.jpg"])
+
+chat("Does Chatlet support streaming responses?")
+
+ chat = Chatlet()
+stream = chat("Tell me a story in 10 words.", stream=True)
+for chunk in stream:
+ print(chunk, end='', flush=True)
+ # call `chat.cancel()` at any time to stop the streaming request
+
+chat("Can I cancel the stream?")
+
+ chat = Chatlet()
+stream = chat("Tell me a very long story.", stream=True)
+for chunk in stream:
+ print(chunk, end='', flush=True)
+ if some_condition: # e.g., user input or time limit
+ chat.cancel()
+ break
+ You can call chat.cancel()
at any time to stop the streaming request. This allows you to interrupt the stream based on certain conditions, such as user input or a time limit.
+chat("Where are the docs?")
+
+ This repository contains detailed information about Chatlet's features, usage examples, and installation instructions.
+