Skip to content

Commit 1ccc7d4

Browse files
Merge pull request #42 from dreamer-coding/main
2 parents 0620dff + 2ecd516 commit 1ccc7d4

File tree

13 files changed

+7508
-2933
lines changed

13 files changed

+7508
-2933
lines changed

code/logic/fossil/ai/iochat.h

Lines changed: 129 additions & 129 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ extern "C"
4444
* @param context_name Optional name for the context/session.
4545
* @return 0 on success, non-zero on failure.
4646
*/
47-
int fossil_io_chat_start(const char *context_name, fossil_jellyfish_chain_t *chain);
47+
int fossil_ai_iochat_start(const char *context_name, fossil_ai_jellyfish_chain_t *chain);
4848

4949
/**
5050
* @brief Processes a user input and generates a chatbot response.
@@ -57,7 +57,7 @@ int fossil_io_chat_start(const char *context_name, fossil_jellyfish_chain_t *cha
5757
* @param size Size of output buffer.
5858
* @return 0 if response found, -1 if unknown.
5959
*/
60-
int fossil_io_chat_respond(fossil_jellyfish_chain_t *chain, const char *input, char *output, size_t size);
60+
int fossil_ai_iochat_respond(fossil_ai_jellyfish_chain_t *chain, const char *input, char *output, size_t size);
6161

6262
/**
6363
* @brief Ends the current conversation session and performs cleanup.
@@ -66,7 +66,7 @@ int fossil_io_chat_respond(fossil_jellyfish_chain_t *chain, const char *input, c
6666
*
6767
* @return 0 on success.
6868
*/
69-
int fossil_io_chat_end(fossil_jellyfish_chain_t *chain);
69+
int fossil_ai_iochat_end(fossil_ai_jellyfish_chain_t *chain);
7070

7171
/**
7272
* @brief Injects a system message into the chain (e.g. "Hello", "System Ready").
@@ -77,7 +77,7 @@ int fossil_io_chat_end(fossil_jellyfish_chain_t *chain);
7777
* @param message System-level message.
7878
* @return 0 on success.
7979
*/
80-
int fossil_io_chat_inject_system_message(fossil_jellyfish_chain_t *chain, const char *message);
80+
int fossil_ai_iochat_inject_system_message(fossil_ai_jellyfish_chain_t *chain, const char *message);
8181

8282
/**
8383
* @brief Appends a chatbot-generated response to the chain memory.
@@ -89,15 +89,15 @@ int fossil_io_chat_inject_system_message(fossil_jellyfish_chain_t *chain, const
8989
* @param output Chatbot response to learn.
9090
* @return 0 on success.
9191
*/
92-
int fossil_io_chat_learn_response(fossil_jellyfish_chain_t *chain, const char *input, const char *output);
92+
int fossil_ai_iochat_learn_response(fossil_ai_jellyfish_chain_t *chain, const char *input, const char *output);
9393

9494
/**
9595
* @brief Returns the number of conversational turns remembered.
9696
*
9797
* @param chain Jellyfish chain.
9898
* @return Number of user-input/output pairs.
9999
*/
100-
int fossil_io_chat_turn_count(const fossil_jellyfish_chain_t *chain);
100+
int fossil_ai_iochat_turn_count(const fossil_ai_jellyfish_chain_t *chain);
101101

102102
/**
103103
* @brief Summarizes the session into a concise text form.
@@ -109,7 +109,7 @@ int fossil_io_chat_turn_count(const fossil_jellyfish_chain_t *chain);
109109
* @param size Size of the output buffer.
110110
* @return 0 on success, -1 if summary couldn't be generated.
111111
*/
112-
int fossil_io_chat_summarize_session(const fossil_jellyfish_chain_t *chain, char *summary, size_t size);
112+
int fossil_ai_iochat_summarize_session(const fossil_ai_jellyfish_chain_t *chain, char *summary, size_t size);
113113

114114
/**
115115
* @brief Filters the most recent N turns into a temporary sub-chain.
@@ -121,7 +121,7 @@ int fossil_io_chat_summarize_session(const fossil_jellyfish_chain_t *chain, char
121121
* @param turn_count Number of recent user turns to include.
122122
* @return 0 on success.
123123
*/
124-
int fossil_io_chat_filter_recent(const fossil_jellyfish_chain_t *chain, fossil_jellyfish_chain_t *out_chain, int turn_count);
124+
int fossil_ai_iochat_filter_recent(const fossil_ai_jellyfish_chain_t *chain, fossil_ai_jellyfish_chain_t *out_chain, int turn_count);
125125

126126
/**
127127
* @brief Exports the current conversation history to a text file.
@@ -130,7 +130,7 @@ int fossil_io_chat_filter_recent(const fossil_jellyfish_chain_t *chain, fossil_j
130130
* @param filepath Destination path for output.
131131
* @return 0 on success, -1 on error.
132132
*/
133-
int fossil_io_chat_export_history(const fossil_jellyfish_chain_t *chain, const char *filepath);
133+
int fossil_ai_iochat_export_history(const fossil_ai_jellyfish_chain_t *chain, const char *filepath);
134134

135135
/**
136136
* @brief Imports a context file and loads it into the chain.
@@ -141,7 +141,7 @@ int fossil_io_chat_export_history(const fossil_jellyfish_chain_t *chain, const c
141141
* @param filepath Source path of saved context.
142142
* @return 0 on success, -1 if parsing fails.
143143
*/
144-
int fossil_io_chat_import_context(fossil_jellyfish_chain_t *chain, const char *filepath);
144+
int fossil_ai_iochat_import_context(fossil_ai_jellyfish_chain_t *chain, const char *filepath);
145145

146146
#ifdef __cplusplus
147147
}
@@ -151,136 +151,136 @@ int fossil_io_chat_import_context(fossil_jellyfish_chain_t *chain, const char *f
151151

152152
namespace fossil {
153153

154-
namespace ai {
154+
namespace ai {
155155

156-
class IOChat {
157-
public:
158-
/**
159-
* @brief Starts a new conversation session.
160-
*
161-
* Initializes a context for handling multi-turn dialogue.
162-
*
163-
* @param context_name Optional name for the context/session.
164-
* @return 0 on success, non-zero on failure.
165-
*/
166-
static int start(const char *context_name, fossil_jellyfish_chain_t *chain) {
167-
return fossil_io_chat_start(context_name, chain);
168-
}
156+
class IOChat {
157+
public:
158+
/**
159+
* @brief Starts a new conversation session.
160+
*
161+
* Initializes a context for handling multi-turn dialogue.
162+
*
163+
* @param context_name Optional name for the context/session.
164+
* @return 0 on success, non-zero on failure.
165+
*/
166+
static int start(const char *context_name, fossil_ai_jellyfish_chain_t *chain) {
167+
return fossil_ai_iochat_start(context_name, chain);
168+
}
169169

170-
/**
171-
* @brief Processes a user input and generates a chatbot response.
172-
*
173-
* Leverages the Jellyfish memory chain to reason about the input.
174-
*
175-
* @param input User input string.
176-
* @param output Output buffer to receive response.
177-
* @param size Size of output buffer.
178-
* @return 0 if response found, -1 if unknown.
179-
*/
180-
static int respond(fossil_jellyfish_chain_t *chain, const char *input, char *output, size_t size) {
181-
return fossil_io_chat_respond(chain, input, output, size);
182-
}
170+
/**
171+
* @brief Processes a user input and generates a chatbot response.
172+
*
173+
* Leverages the Jellyfish memory chain to reason about the input.
174+
*
175+
* @param input User input string.
176+
* @param output Output buffer to receive response.
177+
* @param size Size of output buffer.
178+
* @return 0 if response found, -1 if unknown.
179+
*/
180+
static int respond(fossil_ai_jellyfish_chain_t *chain, const char *input, char *output, size_t size) {
181+
return fossil_ai_iochat_respond(chain, input, output, size);
182+
}
183183

184-
/**
185-
* @brief Ends the current conversation session and performs cleanup.
186-
*
187-
* Frees temporary memory, flushes session logs, or persists updates.
188-
*
189-
* @return 0 on success.
190-
*/
191-
static int end(fossil_jellyfish_chain_t *chain) {
192-
return fossil_io_chat_end(chain);
193-
}
184+
/**
185+
* @brief Ends the current conversation session and performs cleanup.
186+
*
187+
* Frees temporary memory, flushes session logs, or persists updates.
188+
*
189+
* @return 0 on success.
190+
*/
191+
static int end(fossil_ai_jellyfish_chain_t *chain) {
192+
return fossil_ai_iochat_end(chain);
193+
}
194194

195-
/**
196-
* @brief Injects a system message into the chain (e.g. "Hello", "System Ready").
197-
*
198-
* System messages are logged as immutable memory blocks with device signature.
199-
*
200-
* @param message System-level message.
201-
* @return 0 on success.
202-
*/
203-
static int inject_system_message(fossil_jellyfish_chain_t *chain, const char *message) {
204-
return fossil_io_chat_inject_system_message(chain, message);
205-
}
195+
/**
196+
* @brief Injects a system message into the chain (e.g. "Hello", "System Ready").
197+
*
198+
* System messages are logged as immutable memory blocks with device signature.
199+
*
200+
* @param message System-level message.
201+
* @return 0 on success.
202+
*/
203+
static int inject_system_message(fossil_ai_jellyfish_chain_t *chain, const char *message) {
204+
return fossil_ai_iochat_inject_system_message(chain, message);
205+
}
206206

207-
/**
208-
* @brief Learns a new response based on user input and chatbot output.
209-
*
210-
* Updates the Jellyfish memory chain with the new information.
211-
*
212-
* @param input User input string.
213-
* @param output Chatbot output string.
214-
* @return 0 on success, -1 on error.
215-
*/
216-
static int learn_response(fossil_jellyfish_chain_t *chain, const char *input, const char *output) {
217-
return fossil_io_chat_learn_response(chain, input, output);
218-
}
207+
/**
208+
* @brief Learns a new response based on user input and chatbot output.
209+
*
210+
* Updates the Jellyfish memory chain with the new information.
211+
*
212+
* @param input User input string.
213+
* @param output Chatbot output string.
214+
* @return 0 on success, -1 on error.
215+
*/
216+
static int learn_response(fossil_ai_jellyfish_chain_t *chain, const char *input, const char *output) {
217+
return fossil_ai_iochat_learn_response(chain, input, output);
218+
}
219219

220-
/**
221-
* @brief Returns the number of conversational turns remembered.
222-
*
223-
* @param chain Jellyfish chain.
224-
* @return Number of user-input/output pairs.
225-
*/
226-
static int turn_count(const fossil_jellyfish_chain_t *chain) {
227-
return fossil_io_chat_turn_count(chain);
228-
}
220+
/**
221+
* @brief Returns the number of conversational turns remembered.
222+
*
223+
* @param chain Jellyfish chain.
224+
* @return Number of user-input/output pairs.
225+
*/
226+
static int turn_count(const fossil_ai_jellyfish_chain_t *chain) {
227+
return fossil_ai_iochat_turn_count(chain);
228+
}
229229

230-
/**
231-
* @brief Summarizes the session into a concise text form.
232-
*
233-
* This scans the chat blocks and returns a summary paragraph based on user turns.
234-
*
235-
* @param chain Jellyfish chain to summarize.
236-
* @param summary Output buffer to store summary.
237-
* @param size Size of the output buffer.
238-
* @return 0 on success, -1 if summary couldn't be generated.
239-
*/
240-
static int summarize_session(const fossil_jellyfish_chain_t *chain, char *summary, size_t size) {
241-
return fossil_io_chat_summarize_session(chain, summary, size);
242-
}
230+
/**
231+
* @brief Summarizes the session into a concise text form.
232+
*
233+
* This scans the chat blocks and returns a summary paragraph based on user turns.
234+
*
235+
* @param chain Jellyfish chain to summarize.
236+
* @param summary Output buffer to store summary.
237+
* @param size Size of the output buffer.
238+
* @return 0 on success, -1 if summary couldn't be generated.
239+
*/
240+
static int summarize_session(const fossil_ai_jellyfish_chain_t *chain, char *summary, size_t size) {
241+
return fossil_ai_iochat_summarize_session(chain, summary, size);
242+
}
243243

244-
/**
245-
* @brief Filters the most recent N turns into a temporary sub-chain.
246-
*
247-
* Useful for generating context-limited decisions.
248-
*
249-
* @param chain Original chat chain.
250-
* @param out_chain Output chain filled with most recent turns.
251-
* @param turn_count Number of recent user turns to include.
252-
* @return 0 on success.
253-
*/
254-
static int filter_recent(const fossil_jellyfish_chain_t *chain, fossil_jellyfish_chain_t *out_chain, int turn_count) {
255-
return fossil_io_chat_filter_recent(chain, out_chain, turn_count);
256-
}
244+
/**
245+
* @brief Filters the most recent N turns into a temporary sub-chain.
246+
*
247+
* Useful for generating context-limited decisions.
248+
*
249+
* @param chain Original chat chain.
250+
* @param out_chain Output chain filled with most recent turns.
251+
* @param turn_count Number of recent user turns to include.
252+
* @return 0 on success.
253+
*/
254+
static int filter_recent(const fossil_ai_jellyfish_chain_t *chain, fossil_ai_jellyfish_chain_t *out_chain, int turn_count) {
255+
return fossil_ai_iochat_filter_recent(chain, out_chain, turn_count);
256+
}
257257

258-
/**
259-
* @brief Exports the current conversation history to a text file.
260-
*
261-
* @param chain Jellyfish chain to serialize.
262-
* @param filepath Destination path for output.
263-
* @return 0 on success, -1 on error.
264-
*/
265-
static int export_history(const fossil_jellyfish_chain_t *chain, const char *filepath) {
266-
return fossil_io_chat_export_history(chain, filepath);
267-
}
258+
/**
259+
* @brief Exports the current conversation history to a text file.
260+
*
261+
* @param chain Jellyfish chain to serialize.
262+
* @param filepath Destination path for output.
263+
* @return 0 on success, -1 on error.
264+
*/
265+
static int export_history(const fossil_ai_jellyfish_chain_t *chain, const char *filepath) {
266+
return fossil_ai_iochat_export_history(chain, filepath);
267+
}
268268

269-
/**
270-
* @brief Imports a context file and loads it into the chain.
271-
*
272-
* Useful for bootstrapping or restoring previous sessions.
273-
*
274-
* @param chain Destination Jellyfish chain.
275-
* @param filepath Source path of saved context.
276-
* @return 0 on success, -1 if parsing fails.
277-
*/
278-
static int import_context(fossil_jellyfish_chain_t *chain, const char *filepath) {
279-
return fossil_io_chat_import_context(chain, filepath);
280-
}
281-
};
269+
/**
270+
* @brief Imports a context file and loads it into the chain.
271+
*
272+
* Useful for bootstrapping or restoring previous sessions.
273+
*
274+
* @param chain Destination Jellyfish chain.
275+
* @param filepath Source path of saved context.
276+
* @return 0 on success, -1 if parsing fails.
277+
*/
278+
static int import_context(fossil_ai_jellyfish_chain_t *chain, const char *filepath) {
279+
return fossil_ai_iochat_import_context(chain, filepath);
280+
}
281+
};
282282

283-
} // namespace ai
283+
} // namespace ai
284284

285285
} // namespace fossil
286286

0 commit comments

Comments
 (0)