Integrating Thesys C1 API in an existing application
Change baseURL to C1
Add the C1Component to your application
Markdown
component with the C1Component
component.Inter
. You can import this font in your CSS file as follows:(Optional) Streaming the responses
<C1Component />
supports streaming the responses and progressively rendering the UI by passing the isStreaming
prop.
This prop should be set to true
when the response is being streamed and false
when the response is done streaming.isStreaming
as a state variable that is set to true
when the fetch
request is made and set to false
when the request is complete.At this point, you should be able to see your application streaming the responses and progressively rendering the UI.Enabling interactivity
onAction
callback to the C1Component
and implement the logic to handle the action.In most cases, you will want to treat the onAction
callback as a way to trigger the next turn of the conversation.
This means it will function as if the user had typed in a query and hit enter.llmFriendlyMessage
would not be suitable for humans to read in most cases.
Your message store probably won’t have the llmFriendlyMessage
in it but in the long term, it is a good idea to store it in the message store.Once you’ve implemented this all the buttons and forms should be functional.Saving form values
c1Response
object. To enable persistence,
you can pass the updateMessage
callback to the C1Component
and implement the logic to persist the form values.Typically PUT
or PATCH
requests are used to update the message in the database.
You might have to implement this endpoint in your backend if it’s not already implemented.