File tree Expand file tree Collapse file tree 5 files changed +63
-2
lines changed Expand file tree Collapse file tree 5 files changed +63
-2
lines changed Original file line number Diff line number Diff line change @@ -6,7 +6,7 @@ MANPREFIX ?= "$(PREFIX)/share/man/"
66SHAREPREFIX ?= "$(PREFIX ) /share/ai-cli"
77
88PROGS =rl_driver $(SHARED_LIB )
9- RL_SRC =ai_cli.c config.c ini.c fetch_anthropic.c fetch_openai.c \
9+ RL_SRC =ai_cli.c config.c ini.c fetch_anthropic.c fetch_hal.c fetch_openai.c \
1010 fetch_llamacpp.c support.c
1111TEST_SRC =$(wildcard * _test.c)
1212LIB =-lcurl -ljansson
Original file line number Diff line number Diff line change @@ -79,7 +79,7 @@ It can be used when Emacs key bindings are in effect.
7979.PP
8080\fI api= \fR
8181.RS 4
82- Specify the API to use: one of anthropic, llamacpp, or openai.
82+ Specify the API to use: one of anthropic, hal, llamacpp, or openai.
8383.RE
8484
8585.PP
Original file line number Diff line number Diff line change 3030#include "config.h"
3131
3232#include "fetch_anthropic.h"
33+ #include "fetch_hal.h"
3334#include "fetch_llamacpp.h"
3435#include "fetch_openai.h"
3536
@@ -140,6 +141,8 @@ setup(void)
140141 REQUIRE (anthropic , key );
141142 REQUIRE (anthropic , endpoint );
142143 REQUIRE (anthropic , version );
144+ } else if (strcmp (config .general_api , "hal" ) == 0 ) {
145+ fetch = fetch_hal ;
143146 } else if (strcmp (config .general_api , "llamacpp" ) == 0 ) {
144147 fetch = fetch_llamacpp ;
145148 REQUIRE (llamacpp , endpoint );
Original file line number Diff line number Diff line change 1+ /*-
2+ *
3+ * ai-cli - readline wrapper to obtain a generative AI suggestion
4+ * Dummy HAL 9000 access function, that can be used for testing.
5+ *
6+ * Copyright 2024 Diomidis Spinellis
7+ *
8+ * Licensed under the Apache License, Version 2.0 (the "License");
9+ * you may not use this file except in compliance with the License.
10+ * You may obtain a copy of the License at
11+ *
12+ * http://www.apache.org/licenses/LICENSE-2.0
13+ *
14+ * Unless required by applicable law or agreed to in writing, software
15+ * distributed under the License is distributed on an "AS IS" BASIS,
16+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17+ * See the License for the specific language governing permissions and
18+ * limitations under the License.
19+ */
20+
21+ #include "config.h"
22+ #include "fetch_hal.h"
23+
24+ /*
25+ * Fetch response from the dummy HAL 9000 API.
26+ * See https://en.wikipedia.org/wiki/HAL_9000 and
27+ * https://en.wikiquote.org/wiki/2001:_A_Space_Odyssey_(film).
28+ * This endpoint can be used for testing the ai-cli-lib functionality
29+ * without the need to use a networked API.
30+ */
31+ char *
32+ fetch_hal (config_t * config , const char * prompt , int history_length )
33+ {
34+ return "# I'm sorry, Dave. I'm afraid I can't do that." ;
35+ }
Original file line number Diff line number Diff line change 1+ /*-
2+ *
3+ * ai-cli - readline wrapper to obtain a generative AI suggestion
4+ * Dummy HAL 9000 access function, that can be used for testing.
5+ *
6+ * Copyright 2023 Diomidis Spinellis
7+ *
8+ * Licensed under the Apache License, Version 2.0 (the "License");
9+ * you may not use this file except in compliance with the License.
10+ * You may obtain a copy of the License at
11+ *
12+ * http://www.apache.org/licenses/LICENSE-2.0
13+ *
14+ * Unless required by applicable law or agreed to in writing, software
15+ * distributed under the License is distributed on an "AS IS" BASIS,
16+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17+ * See the License for the specific language governing permissions and
18+ * limitations under the License.
19+ */
20+
21+ #include "config.h"
22+
23+ char * fetch_hal (config_t * config , const char * prompt , int history_length );
You can’t perform that action at this time.
0 commit comments