-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
fae7d4e
commit 25dcc98
Showing
39 changed files
with
2,074 additions
and
3,546 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import type { AgentHistory, AgentHistoryAddParams } from '@/.'; | ||
import { | ||
agentResponseResponseSchema, | ||
isAgentHistoryUserItem, | ||
} from '@/agent/types.js'; | ||
import { CodeLlmError } from '@/error/index.js'; | ||
|
||
const agentHistory: AgentHistory = []; | ||
|
||
export const getHistory = () => agentHistory; | ||
|
||
export const addToHistory = (params: AgentHistoryAddParams) => { | ||
try { | ||
const validAgentResponse = agentResponseResponseSchema.parse(params); | ||
const { code, content, reason } = validAgentResponse; | ||
return agentHistory.push({ | ||
code, | ||
content, | ||
reason, | ||
role: 'assistant', | ||
}); | ||
} catch (error) { | ||
// ignore | ||
} | ||
|
||
if (!isAgentHistoryUserItem(params)) { | ||
return new CodeLlmError({ code: 'agent:addHistory', meta: { params } }); | ||
} | ||
|
||
return agentHistory.push(params); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.