midscene icon indicating copy to clipboard operation
midscene copied to clipboard

[Feature] llm Options

Open 729993031 opened this issue 1 year ago • 1 comments

Background

I wish to experiment with other LLM models like Tongyi or Claude, but it's not feasible.

https://github.com/web-infra-dev/midscene/blob/863e5a54d0380004038b6012d4810d79a437a401/packages/midscene/src/ai-model/openai/index.ts#L94

Aspiration

Provide a solution akin to browser-use, allowing the integration of custom models.

import { OpenAI } from "@langchain/openai";

const llm = new OpenAI({
  model: "gpt-3.5-turbo-instruct",
  temperature: 0,
  maxTokens: undefined,
  timeout: undefined,
  maxRetries: 2,
  apiKey: process.env.OPENAI_API_KEY,
  // other params...
});
const mid = new PuppeteerAgent(page,{llm});

Benefits

  1. less code、lower maintenance complexity
  2. The token cost of GPT-4 is relatively high; in certain scenarios, cheaper models can be employed to achieve similar outcomes.

729993031 avatar Dec 14 '24 13:12 729993031

Try these params: https://midscenejs.com/model-provider.html

That should work for you.

yuyutaotao avatar Dec 17 '24 02:12 yuyutaotao