Chore: tools to their own file [wip]
This commit is contained in:
@@ -6,7 +6,7 @@
|
|||||||
- regen last message; +
|
- regen last message; +
|
||||||
- delete last message; +
|
- delete last message; +
|
||||||
- edit message? (including from bot); +
|
- edit message? (including from bot); +
|
||||||
- ability to copy message;
|
- ability to copy message; +
|
||||||
- aility to copy selected text; (I can do it though vim mode of the terminal, so +)
|
- aility to copy selected text; (I can do it though vim mode of the terminal, so +)
|
||||||
- menu with old chats (chat files); +
|
- menu with old chats (chat files); +
|
||||||
- fullscreen textarea option (for long prompt);
|
- fullscreen textarea option (for long prompt);
|
||||||
|
|||||||
39
bot.go
39
bot.go
@@ -44,47 +44,8 @@ var (
|
|||||||
{Role: assistantRole, Content: defaultFirstMsg},
|
{Role: assistantRole, Content: defaultFirstMsg},
|
||||||
}
|
}
|
||||||
interruptResp = false
|
interruptResp = false
|
||||||
systemMsg = `You're a helpful assistant.
|
|
||||||
# Tools
|
|
||||||
You can do functions call if needed.
|
|
||||||
Your current tools:
|
|
||||||
<tools>
|
|
||||||
{
|
|
||||||
"name":"get_id",
|
|
||||||
"args": "username"
|
|
||||||
}
|
|
||||||
</tools>
|
|
||||||
To make a function call return a json object within __tool_call__ tags;
|
|
||||||
Example:
|
|
||||||
__tool_call__
|
|
||||||
{
|
|
||||||
"name":"get_id",
|
|
||||||
"args": "Adam"
|
|
||||||
}
|
|
||||||
__tool_call___
|
|
||||||
When making function call avoid typing anything else. 'tool' user will respond with the results of the call.
|
|
||||||
After that you are free to respond to the user.
|
|
||||||
`
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// predifine funcs
|
|
||||||
func getUserDetails(id ...string) map[string]any {
|
|
||||||
// db query
|
|
||||||
// return DB[id[0]]
|
|
||||||
return map[string]any{
|
|
||||||
"username": "fm11",
|
|
||||||
"id": 24983,
|
|
||||||
"reputation": 911,
|
|
||||||
"balance": 214.73,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
type fnSig func(...string) map[string]any
|
|
||||||
|
|
||||||
var fnMap = map[string]fnSig{
|
|
||||||
"get_id": getUserDetails,
|
|
||||||
}
|
|
||||||
|
|
||||||
// ====
|
// ====
|
||||||
|
|
||||||
func getUserInput(userPrompt string) string {
|
func getUserInput(userPrompt string) string {
|
||||||
|
|||||||
1
main.go
1
main.go
@@ -172,7 +172,6 @@ func main() {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
if event.Key() == tcell.KeyF3 {
|
if event.Key() == tcell.KeyF3 {
|
||||||
// TODO: delete last n messages
|
|
||||||
// modal window with input field
|
// modal window with input field
|
||||||
chatBody.Messages = chatBody.Messages[:len(chatBody.Messages)-1]
|
chatBody.Messages = chatBody.Messages[:len(chatBody.Messages)-1]
|
||||||
textView.SetText(chatToText(showSystemMsgs))
|
textView.SetText(chatToText(showSystemMsgs))
|
||||||
|
|||||||
@@ -20,3 +20,8 @@ func (c Chat) ToHistory() ([]MessagesStory, error) {
|
|||||||
}
|
}
|
||||||
return resp, nil
|
return resp, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type Memory struct {
|
||||||
|
Topic string `db:"topic" json:"topic"`
|
||||||
|
Data string `db:"data" json:"data"`
|
||||||
|
}
|
||||||
|
|||||||
59
tools.go
Normal file
59
tools.go
Normal file
@@ -0,0 +1,59 @@
|
|||||||
|
package main
|
||||||
|
|
||||||
|
var (
|
||||||
|
// TODO: form that message based on existing funcs
|
||||||
|
systemMsg = `You're a helpful assistant.
|
||||||
|
# Tools
|
||||||
|
You can do functions call if needed.
|
||||||
|
Your current tools:
|
||||||
|
<tools>
|
||||||
|
{
|
||||||
|
"name":"get_id",
|
||||||
|
"args": "username"
|
||||||
|
}
|
||||||
|
</tools>
|
||||||
|
To make a function call return a json object within __tool_call__ tags;
|
||||||
|
Example:
|
||||||
|
__tool_call__
|
||||||
|
{
|
||||||
|
"name":"get_id",
|
||||||
|
"args": "Adam"
|
||||||
|
}
|
||||||
|
__tool_call__
|
||||||
|
When making function call avoid typing anything else. 'tool' user will respond with the results of the call.
|
||||||
|
After that you are free to respond to the user.
|
||||||
|
`
|
||||||
|
)
|
||||||
|
|
||||||
|
func memorize(topic, info string) {
|
||||||
|
//
|
||||||
|
}
|
||||||
|
|
||||||
|
func recall(topic string) string {
|
||||||
|
//
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
|
||||||
|
func recallTopics() []string {
|
||||||
|
return []string{}
|
||||||
|
}
|
||||||
|
|
||||||
|
func fullMemoryLoad() {}
|
||||||
|
|
||||||
|
// predifine funcs
|
||||||
|
func getUserDetails(id ...string) map[string]any {
|
||||||
|
// db query
|
||||||
|
// return DB[id[0]]
|
||||||
|
return map[string]any{
|
||||||
|
"username": "fm11",
|
||||||
|
"id": 24983,
|
||||||
|
"reputation": 911,
|
||||||
|
"balance": 214.73,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
type fnSig func(...string) map[string]any
|
||||||
|
|
||||||
|
var fnMap = map[string]fnSig{
|
||||||
|
"get_id": getUserDetails,
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user