@surph_ai/sdk 0.0.2 → 0.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,21 @@
1
+ {
2
+ "name": "base-template",
3
+ "version": "0.0.0",
4
+ "private": true,
5
+ "scripts": {
6
+ "start": "node ./server/app",
7
+ "dev": "nodemon",
8
+ "test": "",
9
+ "build": ""
10
+ },
11
+ "dependencies": {
12
+ "@surph_ai/sdk": "latest",
13
+ "@vinely-ai/sdk": "^0.0.6",
14
+ "cookie": "^0.5.0",
15
+ "express": "^4.18.1",
16
+ "mustache": "^4.2.0"
17
+ },
18
+ "devDependencies": {
19
+ "nodemon": "^2.0.2"
20
+ }
21
+ }
@@ -0,0 +1,17 @@
1
+ const express = require('express')
2
+ const vinely = require('@vinely-ai/sdk')
3
+
4
+ const app = express()
5
+
6
+ vinely.configureApp(app, {
7
+ views: 'server/templates',
8
+ static: 'public',
9
+ })
10
+
11
+ const index = require('./routes/index')
12
+ const tool = require('./routes/tool')
13
+
14
+ app.use('/', index)
15
+ app.use('/tools', tool)
16
+
17
+ module.exports.entry = vinely.server(app)
@@ -0,0 +1,8 @@
1
+ const { Router } = require('express')
2
+ const router = Router()
3
+
4
+ router.get('/', (req, res, next) => {
5
+ res.render('index', {})
6
+ })
7
+
8
+ module.exports = router
@@ -0,0 +1,67 @@
1
+ const { Router, response } = require('express')
2
+ const tools = require('../../tools')
3
+
4
+ const router = Router()
5
+
6
+ const handler = async (args, tool) => {
7
+ let payload = null
8
+ let errorMsg = null
9
+ try {
10
+ payload = await tool(args)
11
+ } catch (error) {
12
+ errorMsg = error instanceof Error ? error.message : String(error)
13
+ } finally {
14
+ return {
15
+ success: errorMsg === null ? true : false,
16
+ payload
17
+ }
18
+ }
19
+ }
20
+
21
+ router.get('/:tool', async (req, res, next) => {
22
+ try {
23
+ const tool = tools[req.params.tool]
24
+ if (!tool) {
25
+ throw new Error(`Tool ${req.params.tool} not found.`)
26
+ }
27
+
28
+ const response = await handler(req.query, tool)
29
+ res.json({ response })
30
+ } catch (error) {
31
+ res.json({
32
+ response: {
33
+ success: false,
34
+ error: error.message
35
+ }
36
+ })
37
+ }
38
+ })
39
+
40
+ router.post('/custom', async (req, res, next) => {
41
+ // console.log('TOOL CALL: ' + JSON.stringify(req.body))
42
+ // {"name":"youtube-transcript","args":{"video":"m7kw0AhrMvQ"},"tool":{"name":"youtube-transcript","slug":"y2script","type":"custom","description":"Fetch the plain-text transcript (spoken words) of a YouTube video. Use this whenever the user asks about, quotes from, summarizes, or wants to search inside the content of a YouTube video — including questions like \"what does this video say about X\", \"summarize this video\", \"pull the transcript\", or when the user pastes a YouTube URL and expects you to know its contents. Do NOT use this for general video metadata (title, channel, view count) or for non-YouTube videos.","parameters":{"type":"object","properties":{"video":{"type":"string","description":"The YouTube video to transcribe. Accepts either a full URL (e.g. \"https://www.youtube.com/watch?v=EwusdkKUlwI\", \"https://youtu.be/EwusdkKUlwI\") or the bare 11-character video id (e.g. \"EwusdkKUlwI\"). Extract this from the user's message when they paste a link."}},"required":["video"]}},"user":{"id":"6a3d402f0817076e079e7398","username":"dkwon"}}
43
+
44
+ try {
45
+ const { name, args, tool, user = null } = req.body;
46
+ console.log('TOOL CALL: ' + name)
47
+ // console.log('TOOL ARGS: ' + JSON.stringify(args))
48
+
49
+ const _tool = tools[tool.slug]
50
+ if (!_tool) {
51
+ throw new Error(`Tool ${tool.name} not found.`)
52
+ }
53
+
54
+ const response = await handler(args, _tool)
55
+ // console.log('TOOL RESP: ' + JSON.stringify(response))
56
+ res.json({ response })
57
+ } catch (error) {
58
+ res.json({
59
+ response: {
60
+ success: false,
61
+ error: error.message
62
+ }
63
+ })
64
+ }
65
+ })
66
+
67
+ module.exports = router
@@ -0,0 +1,20 @@
1
+ <!DOCTYPE html>
2
+ <html dir="ltr" lang="en-US">
3
+ <head>
4
+ <meta charset="UTF-8">
5
+ <meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
6
+ <meta http-equiv="X-UA-Compatible" content="ie=edge">
7
+ <meta http-equiv="Content-Language" content="en" />
8
+
9
+ <title>Surph AI</title>
10
+ <link rel="shortcut icon" href="https://lh3.googleusercontent.com/MpnmfR3zYPTojA03QbhGgwIHucmH5s4G2vbIlADYhODL488MQt_BuVztv9LYmJbhwkScYN0DIXuh4d10YMsLbWXT">
11
+ <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css">
12
+ <link rel="stylesheet" href="https://cdn.turbo360-dev.com/admin/assets/scaffold/css/style.min.css" />
13
+ </head>
14
+
15
+ <body>
16
+ <div class="container pt-5">
17
+ <h1>Welcome to Surph AI</h1>
18
+ </div>
19
+ </body>
20
+ </html>
@@ -0,0 +1,8 @@
1
+ // Your tools code goes here. When ready to get, register
2
+ // tool name in exports at bottom of this file:
3
+
4
+ module.exports = {
5
+ demo: (args) => {
6
+ return `this is a sample tool: ${JSON.stringify(args)}`
7
+ }
8
+ }
@@ -1,12 +0,0 @@
1
- const gulp = require('gulp')
2
- const babel = require('gulp-babel')
3
-
4
- gulp.task('build', () => {
5
- return gulp.src(['../src/**'])
6
- .pipe(babel({
7
- presets: ['@babel/preset-env']
8
- }))
9
- .pipe(gulp.dest('../dist'))
10
- })
11
-
12
- gulp.task('default', gulp.series('build'))
@@ -1,24 +0,0 @@
1
- {
2
- "version": "1.0.0",
3
- "description": "",
4
- "main": "index.js",
5
- "scripts": {
6
- "test": "echo \"Error: no test specified\" && exit 1",
7
- "build": "turbo build"
8
- },
9
- "babel": {
10
- "presets": ["@babel/env"]
11
- },
12
- "keywords": [],
13
- "license": "ISC",
14
- "dependencies": {
15
- "@turbo360/turbo-sdk": "^0.0.7"
16
- },
17
- "devDependencies": {
18
- "@babel/cli": "^7.21.5",
19
- "@babel/core": "^7.0.0",
20
- "@babel/preset-env": "^7.21.5",
21
- "gulp": "^4.0.2",
22
- "gulp-babel": "^8.0.0"
23
- }
24
- }
@@ -1,14 +0,0 @@
1
- class App {
2
- constructor(_context) {
3
- this.context = _context
4
- }
5
-
6
- async helloWorld() {
7
- return {
8
- text: 'Hello World!',
9
- context: this.context
10
- }
11
- }
12
- }
13
-
14
- module.exports = (turboContext) => new App(turboContext)