Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions c_api/include/Translator.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#ifndef TRANSLATOR_H
#define TRANSLATOR_H

#include <json.h>
#include "common.h"

// Function declarations
const char* prompt_translator(
const char *code,
const char *lang,
const char *ar_docs_dir,
const char *api_key,
JSON *used_libs);

#endif // TRANSLATOR_H
4 changes: 2 additions & 2 deletions c_api/include/WebPlatformEngine.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
void webplatform_free_resources();

char* webplatform_run(
const char *api_key, const char *question,
const char *docs_index_path, const char *rag_index_path,
const char *api_key, const char *question, const char *lang,
const char *docs_index_path, const char *rag_index_path, const char *ar_docs_dir,
const char *model_tag, const char *model_path,
const char *alusus_features_mapper_path, const char *docs_root_dir);

Expand Down
8 changes: 8 additions & 0 deletions c_api/include/common.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,14 @@ typedef struct {
char basic_vdb_path[MAX_LINE_LENGTH];
char basic_index_path[MAX_LINE_LENGTH];
char alusus_features_mapper_path[MAX_LINE_LENGTH];
char ar_docs_dir[MAX_LINE_LENGTH];
} Config;

// constants
#define PATH_MAX 2048
static const char *library_names[] = {
"WebPlatform"
};
static const int num_libraries = sizeof(library_names) / sizeof(library_names[0]);

#endif // COMMON_H
14 changes: 10 additions & 4 deletions c_api/src/BasicEngine.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#include "MainAgent.h"
#include "AlususExpert.h"
#include "KeywordDocsRetriever.h"
#include "Translator.h"
#include "common.h"
#include "utils.h"
#include <c_api/Index_c.h>
Expand Down Expand Up @@ -57,7 +58,7 @@ static float* get_embedding(const char *question, const char *model_path) {

if (model == NULL) {
printf("%s: unable to load model\n", __func__);
return 1;
return NULL;
}
else {
printf("model loaded successfuly!\n");
Expand Down Expand Up @@ -222,8 +223,8 @@ static JSON* get_examples(idx_t *indices, int k, const char *examples_index_path
}

char* basic_run(
const char *api_key, const char *question,
const char* docs_root_dir, const char *docs_index_path,
const char *api_key, const char *question, const char *lang,
const char* docs_root_dir, const char *docs_index_path, const char *ar_docs_dir,
const char *base_model_tag, const char *model_tag,
const char *vdb_path, const char *index_path,
const char *alusus_features_mapper_path, const char *embedding_model_path) {
Expand Down Expand Up @@ -303,7 +304,12 @@ char* basic_run(
const char *final_answer = prompt_alusus_expert(initial_code, keyword_docs, api_key);
printf("\nPrompting Alusus Expert is done successfully\n");

char *formatted_response = format_final_response(final_answer);
// translate the code
printf("\nPrompting Alusus Translator ...\n");
const char *translated_code = prompt_translator(final_answer, lang, ar_docs_dir, api_key, NULL);
printf("\nPrompting Alusus Translator is done successfully\n");

char *formatted_response = format_final_response(translated_code);
//printf("formatted_response:\n%s\n", formatted_response);
return formatted_response;
}
Loading