Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: make Bearer token configurable via SHINKAI_BEARER environment variable #3

Closed
Closed
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
4 changes: 2 additions & 2 deletions test-engine/shinak-api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ async function delete_if_exists(test: TestData) {
url,
method: "delete",
params: { tool_key: key },
headers: { Authorization: `Bearer debug` },
headers: { Authorization: `Bearer ${Deno.env.get("BEARER") ?? "debug"}` },
});
} catch { /* ignore */ }
}
Expand Down Expand Up @@ -50,7 +50,7 @@ export async function save_tool(
url: `${shinkaiApiUrl}/v2/set_playground_tool`,
method: "post",
data: body,
headers: { Authorization: `Bearer debug` },
headers: { Authorization: `Bearer ${Deno.env.get("BEARER") ?? "debug"}` },
});
return response.data.metadata.tool_router_key;
// deno-lint-ignore no-explicit-any
Expand Down
6 changes: 3 additions & 3 deletions test-engine/shinkai-prompts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export async function getAllToolsHeaders(): Promise<{
tools: [],
},
headers: {
Authorization: "Bearer debug",
Authorization: `Bearer ${Deno.env.get("BEARER") ?? "debug"}`,
"Content-Type": "application/json; charset=utf-8",
},
});
Expand All @@ -32,7 +32,7 @@ export async function getAllToolsHeaders(): Promise<{
tools: availableTools.join(","),
},
headers: {
Authorization: "Bearer debug",
Authorization: `Bearer ${Deno.env.get("BEARER") ?? "debug"}`,
"Content-Type": "application/json; charset=utf-8",
},
});
Expand All @@ -56,7 +56,7 @@ export async function getToolImplementationPrompt(
tools: test.tools.join(","),
},
headers: {
Authorization: "Bearer debug",
Authorization: `Bearer ${Deno.env.get("BEARER") ?? "debug"}`,
"Content-Type": "application/json; charset=utf-8",
},
});
Expand Down
14 changes: 8 additions & 6 deletions test-engine/test-exec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ import { Language, TestData } from "../types.ts";
import { PromptTest } from "./PromptTest.ts";
import { Paths } from "./../paths.ts";

const SHINKAI_BEARER = Deno.env.get("SHINKAI_BEARER") ?? "debug";

export function checkIfHeadersPresent(code: string) {
return code.includes("SHINKAI_NODE_LOCATION") &&
code.includes("BEARER")
Expand All @@ -20,7 +22,7 @@ export function appendAditionalCode(
import os
import json
os.environ["SHINKAI_NODE_LOCATION"] = "http://localhost:9950"
os.environ["BEARER"] = "debug"
os.environ["BEARER"] = SHINKAI_BEARER
os.environ["X_SHINKAI_TOOL_ID"] = "tool-id-debug"
os.environ["X_SHINKAI_APP_ID"] = "tool-app-debug"
os.environ["X_SHINKAI_LLM_PROVIDER"] = "${model.shinkaiName}"
Expand All @@ -32,15 +34,15 @@ os.environ["SHINKAI_ASSETS"] = "${Paths.editorAssetsPath(language, test, model)}
`
if __name__ == "__main__":
import asyncio

config = CONFIG()
inputs = INPUTS()
${
Object.keys(test.inputs).map((k) =>
`inputs.${k}=${JSON.stringify(test.inputs[k])}`
).join("\n ")
}

# Run the async function
result = asyncio.run(run(config, inputs))
print(json.dumps(result.__dict__))
Expand All @@ -53,7 +55,7 @@ if __name__ == "__main__":
// These environment variables are required, before any import.
// Do not remove them, as they set environment variables for the Shinkai Tools.
Deno.env.set('SHINKAI_NODE_LOCATION', "http://localhost:9950");
Deno.env.set('BEARER', "debug");
Deno.env.set('BEARER', SHINKAI_BEARER);
Deno.env.set('X_SHINKAI_TOOL_ID', "tool-id-debug");
Deno.env.set('X_SHINKAI_APP_ID', "tool-app-debug");
Deno.env.set('X_SHINKAI_LLM_PROVIDER', "${model.shinkaiName}");
Expand All @@ -63,11 +65,11 @@ if __name__ == "__main__":
`,
code_,
`

// console.log('Running...')
// console.log('Config: ${JSON.stringify(test.config)}')
// console.log('Inputs: ${JSON.stringify(test.inputs)}')

try {
const program_result = await run(${JSON.stringify(test.config)}, ${
JSON.stringify(test.inputs)
Expand Down