You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+50-1Lines changed: 50 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -71,6 +71,55 @@ program.Steps[1].Args == []any{"I have been promoted!"}
71
71
// You can build a program executor on top of this structure.
72
72
```
73
73
74
+
### Error Handling Example
75
+
76
+
When working with external services or APIs, it's crucial to handle errors gracefully. Below is an example of how to handle errors when using the `Execute` method of the `Prompt` struct.
77
+
78
+
```go
79
+
ctx:= context.Background()
80
+
model:= ... // your model client
81
+
82
+
prompt:= typechat.NewPrompt[Classifier](model, "Analyze the sentiment of this text.")
This example demonstrates catching and handling errors returned by the `Execute` method, ensuring that your application can respond appropriately to failures.
93
+
94
+
### Custom Adapter Example
95
+
96
+
To use a custom adapter with the library, you need to create an adapter that implements the `client` interface. Below is an example of how to create a custom adapter and use it with `NewPrompt`.
This example demonstrates creating a custom adapter that implements the `client` interface and using it with `NewPrompt` to send prompts to your custom service.
122
+
74
123
## Contributing
75
124
76
125
This library is under development and still requires more work to solidify the provided APIs so use with caution. A release will be done at some point in the near future.
@@ -83,4 +132,4 @@ This library is under development and still requires more work to solidify the p
83
132
- Figure out best way to stay in sync with the original TypeChat project
0 commit comments