Skip to content

Commit

Permalink
update type infer
Browse files Browse the repository at this point in the history
  • Loading branch information
wtfsayo committed Feb 3, 2025
1 parent ae14092 commit 2d91408
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 7 deletions.
2 changes: 1 addition & 1 deletion packages/core/src/generation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,7 @@ export const generateObject = async ({
verifiableInference,
verifiableInferenceAdapter,
verifiableInferenceOptions,
}: GenerateObjectOptions): Promise<JSONValue> => {
}: GenerateObjectOptions): Promise<z.infer<typeof schema> | JSONValue> => {
logFunctionCall('generateObject', runtime);
if (!context) {
const errorMessage = "generateObject context is empty";
Expand Down
25 changes: 19 additions & 6 deletions packages/plugin-primus/src/adapter/primusAdapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import {
type VerifiableInferenceResult,
VerifiableInferenceProvider,
ModelProviderName,
models,
elizaLogger,
} from "@elizaos/core";
import {generateProof, verifyProof} from "../util/primusUtil.ts";
Expand All @@ -30,8 +29,24 @@ export class PrimusAdapter implements IVerifiableInferenceAdapter {
options?: VerifiableInferenceOptions
): Promise<VerifiableInferenceResult> {
const provider = this.options.modelProvider || ModelProviderName.OPENAI;
const baseEndpoint = options?.endpoint || models[provider].endpoint;
const model = models[provider].model[modelClass];

// Get model settings from runtime configuration
const modelSettings = {
endpoint: options?.endpoint || "https://api.openai.com/v1",
model: {
chat: {
name: "gpt-3.5-turbo",
temperature: 0.7
},
completion: {
name: "text-davinci-003",
temperature: 0.7
}
}
};

const baseEndpoint = modelSettings.endpoint;
const model = modelSettings.model[modelClass] || modelSettings.model.chat;
const apiKey = this.options.token;

if (!apiKey) {
Expand Down Expand Up @@ -65,9 +80,7 @@ export class PrimusAdapter implements IVerifiableInferenceAdapter {
const body = {
model: model.name,
messages: [{ role: "user", content: context }],
temperature:
options?.providerOptions?.temperature ||
models[provider].model[modelClass].temperature,
temperature: options?.providerOptions?.temperature || model.temperature,
};
const attestation = await generateProof(endpoint,"POST",headers,JSON.stringify(body),responseParsePath);
elizaLogger.log("model attestation:", attestation);
Expand Down

0 comments on commit 2d91408

Please sign in to comment.