kopia lustrzana https://github.com/transitive-bullshit/chatgpt-api
				
				
				
			
			
			
			
				pull/643/head^2
			
			
		
		
							rodzic
							
								
									7f098d1ec3
								
							
						
					
					
						commit
						3269e9b67d
					
				
							
								
								
									
										10
									
								
								package.json
								
								
								
								
							
							
						
						
									
										10
									
								
								package.json
								
								
								
								
							| 
						 | 
				
			
			@ -37,6 +37,11 @@
 | 
			
		|||
      "types": "./dist/sdks/genkit.d.ts",
 | 
			
		||||
      "import": "./dist/sdks/genkit.js",
 | 
			
		||||
      "default": "./dist/sdks/genkit.js"
 | 
			
		||||
    },
 | 
			
		||||
    "./calculator": {
 | 
			
		||||
      "types": "./dist/tools/calculator.d.ts",
 | 
			
		||||
      "import": "./dist/tools/calculator.js",
 | 
			
		||||
      "default": "./dist/tools/calculator.js"
 | 
			
		||||
    }
 | 
			
		||||
  },
 | 
			
		||||
  "files": [
 | 
			
		||||
| 
						 | 
				
			
			@ -81,6 +86,7 @@
 | 
			
		|||
    "del-cli": "^5.1.0",
 | 
			
		||||
    "dotenv": "^16.4.5",
 | 
			
		||||
    "eslint": "^8.57.0",
 | 
			
		||||
    "expr-eval": "^2.0.2",
 | 
			
		||||
    "husky": "^9.0.11",
 | 
			
		||||
    "lint-staged": "^15.2.5",
 | 
			
		||||
    "np": "^10.0.5",
 | 
			
		||||
| 
						 | 
				
			
			@ -99,6 +105,7 @@
 | 
			
		|||
    "@dexaai/dexter": "^2.0.3",
 | 
			
		||||
    "@genkit-ai/ai": "^0.5.2",
 | 
			
		||||
    "@langchain/core": "^0.2.5",
 | 
			
		||||
    "expr-eval": "^2.0.2",
 | 
			
		||||
    "ai": "^3.1.22"
 | 
			
		||||
  },
 | 
			
		||||
  "peerDependenciesMeta": {
 | 
			
		||||
| 
						 | 
				
			
			@ -111,6 +118,9 @@
 | 
			
		|||
    "@langchain/core": {
 | 
			
		||||
      "optional": true
 | 
			
		||||
    },
 | 
			
		||||
    "expr-eval": {
 | 
			
		||||
      "optional": true
 | 
			
		||||
    },
 | 
			
		||||
    "ai": {
 | 
			
		||||
      "optional": true
 | 
			
		||||
    }
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -75,6 +75,9 @@ importers:
 | 
			
		|||
      eslint:
 | 
			
		||||
        specifier: ^8.57.0
 | 
			
		||||
        version: 8.57.0
 | 
			
		||||
      expr-eval:
 | 
			
		||||
        specifier: ^2.0.2
 | 
			
		||||
        version: 2.0.2
 | 
			
		||||
      husky:
 | 
			
		||||
        specifier: ^9.0.11
 | 
			
		||||
        version: 9.0.11
 | 
			
		||||
| 
						 | 
				
			
			@ -1914,6 +1917,9 @@ packages:
 | 
			
		|||
    resolution: {integrity: sha512-Fqs7ChZm72y40wKjOFXBKg7nJZvQJmewP5/7LtePDdnah/+FH9Hp5sgMujSCMPXlxOAW2//1jrW9pnsY7o20vQ==}
 | 
			
		||||
    engines: {node: '>=18'}
 | 
			
		||||
 | 
			
		||||
  expr-eval@2.0.2:
 | 
			
		||||
    resolution: {integrity: sha512-4EMSHGOPSwAfBiibw3ndnP0AvjDWLsMvGOvWEZ2F96IGk0bIVdjQisOHxReSkE13mHcfbuCiXw+G4y0zv6N8Eg==}
 | 
			
		||||
 | 
			
		||||
  express@4.19.2:
 | 
			
		||||
    resolution: {integrity: sha512-5T6nhjsT+EOMzuck8JjBHARTHfMht0POzlA60WV2pMD3gyXw2LZnZ+ueGdNxG+0calOJcWKbpFcuzLZ91YWq9Q==}
 | 
			
		||||
    engines: {node: '>= 0.10.0'}
 | 
			
		||||
| 
						 | 
				
			
			@ -6519,6 +6525,8 @@ snapshots:
 | 
			
		|||
 | 
			
		||||
  exit-hook@4.0.0: {}
 | 
			
		||||
 | 
			
		||||
  expr-eval@2.0.2: {}
 | 
			
		||||
 | 
			
		||||
  express@4.19.2:
 | 
			
		||||
    dependencies:
 | 
			
		||||
      accepts: 1.3.8
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -106,13 +106,11 @@ export namespace perigon {
 | 
			
		|||
    q: z.string()
 | 
			
		||||
      .describe(`Search query. It may use boolean operators (AND, OR, NOT) and quotes for exact matching. Example search queries:
 | 
			
		||||
 | 
			
		||||
- AI agents
 | 
			
		||||
- Compare the latest predictions and popular opinions on the 2024 US election
 | 
			
		||||
- election news
 | 
			
		||||
- "elon musk" AND tesla
 | 
			
		||||
- (upcoming release OR launch) AND apple
 | 
			
		||||
- (Google OR Amazon) AND NOT ("Jeff Bezos" OR Android)
 | 
			
		||||
- "climate change"
 | 
			
		||||
- Crypto* OR Bitcoin NOT Ethereum
 | 
			
		||||
`),
 | 
			
		||||
    title: z
 | 
			
		||||
      .string()
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -0,0 +1,22 @@
 | 
			
		|||
import { Parser } from 'expr-eval'
 | 
			
		||||
import { z } from 'zod'
 | 
			
		||||
 | 
			
		||||
import { createAIFunction } from '../create-ai-function.js'
 | 
			
		||||
 | 
			
		||||
export const CalculatorInputSchema = z.object({
 | 
			
		||||
  expr: z.string().describe('mathematical expression to evaluate')
 | 
			
		||||
})
 | 
			
		||||
export type CalculatorInput = z.infer<typeof CalculatorInputSchema>
 | 
			
		||||
 | 
			
		||||
export const calculator = createAIFunction(
 | 
			
		||||
  {
 | 
			
		||||
    name: 'calculator',
 | 
			
		||||
    description:
 | 
			
		||||
      'Computes the result of simple mathematical expressions. Handles basic arithmetic operations like addition, subtraction, multiplication, division, exponentiation, and common functions like sin, cos, abs, exp, and random.',
 | 
			
		||||
    inputSchema: CalculatorInputSchema
 | 
			
		||||
  },
 | 
			
		||||
  async (input: CalculatorInput) => {
 | 
			
		||||
    const result: number = Parser.evaluate(input.expr)
 | 
			
		||||
    return result
 | 
			
		||||
  }
 | 
			
		||||
)
 | 
			
		||||
| 
						 | 
				
			
			@ -6,7 +6,8 @@ export default defineConfig([
 | 
			
		|||
      'src/index.ts',
 | 
			
		||||
      'src/sdks/ai-sdk.ts',
 | 
			
		||||
      'src/sdks/dexter.ts',
 | 
			
		||||
      'src/sdks/genkit.ts'
 | 
			
		||||
      'src/sdks/genkit.ts',
 | 
			
		||||
      'src/tools/calculator.ts'
 | 
			
		||||
    ],
 | 
			
		||||
    outDir: 'dist',
 | 
			
		||||
    target: 'node18',
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Ładowanie…
	
		Reference in New Issue