-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsample.cpp
More file actions
71 lines (60 loc) · 1.82 KB
/
Copy pathsample.cpp
File metadata and controls
71 lines (60 loc) · 1.82 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
#include <windows.h>
#include <iostream>
#include <string>
#include "dotenv.h"
#include "my_rag.hpp"
// extern "C" でC言語リンクとし、__declspec(dllexport) でエクスポート
extern "C" {
__declspec(dllexport) const char* get_embed(const char* input)
{
dotenv env(".env");
std::string query = input;
MyRag rLib("");
std::string result = rLib.get_embed(query);
char* output = new char[result.length() + 1];
strcpy(output, result.c_str());
return output;
}
__declspec(dllexport) const char* chat_post(const char* input)
{
dotenv env(".env");
std::string query = input;
MyRag rLib("");
std::string result = rLib.chat_post(query);
char* output = new char[result.length() + 1];
strcpy(output, result.c_str());
return output;
}
/*
__declspec(dllexport) const char* rag_search(const char* input)
{
dotenv env(".env");
static std::string resp;
std::string api_key = env.get("GEMINI_API_KEY", "key123");
if(api_key == ""){
resp="error , GEMINI_API_KEY none.";
}
std::string query = input;
MyRag rLib("");
resp = rLib.rag_search(query, api_key);
return resp.c_str();
}
*/
__declspec(dllexport) int add(int a, int b) {
return a + b;
}
__declspec(dllexport) double multiply(double a, double b) {
return a * b;
}
__declspec(dllexport) const char* get_message()
{
return "Hello World";
}
__declspec(dllexport) const char* greet(const char* name)
{
static std::string msg;
msg = "Hello ";
msg += name;
return msg.c_str();
}
}