Skip to content

viam-labs/chat-service-api

Repository files navigation

chat-service-api

Protobuf API and gRPC bindings for chat service to use with Viam modules.

chat-service-api proves the protobuf API and gRPC bindings for chat model communication.

API

The chat resource implements the following API:

chat(message=string): answer=string

The chat() command takes:

  • message: the question or prompt to pass to the the chat model

Returns: The answer from the model as a string.

Usage

Python

Because this module uses a custom protobuf-based API, you must include this project in your client code. One way to do this is to include it in your pyproject.yaml or requirements.txt as follows:

chat_service_api @ git+https://github.com/viam-labs/chat-service-api.git@main

It can be imported and used as follows:

from chat_service_api import Chat
chat = Chat.from_robot(robot, "chat")
answer = await chat.chat("What is the meaning of life?")
print(f"Answer: {answer}")

See examples/client.py for a complete example.

Go

Because this module uses a custom protobuf-based API, you must import and use in your client code as follows:

import chat "github.com/viam-labs/chat-service-api/src/chat_go"

chat, err := chat.FromRobot(robot, "chat")
answer, err := chat.chat(context.Background(), "What is the meaning of life?")
fmt.PrintLn(answer)

See examples/client.go for a complete example.

Typescript

Because this module uses a custom protobuf-based API, you must include this project in your client code. One way to do this is to include it in your package.json as follows:

"chat-service-api": "github:viam-labs/chat-service-api",

It is recommended that you include a tag at the end of the github import. You can now use it in your code as follows:

const chat = new ChatClient(client, "chat");
await chat.chat("What is the meaning of life?");

Development

This project is managed by rye. To initialize the development environment, follow the installation instructions and run:

rye sync

To rebuild the gRPC bindings run:

make generate

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

No packages published