Code Monkey home page Code Monkey logo

shortcut_chatgpt_api's Introduction

shortcut_chatgpt_api

This repo's intention is to connect the shortcut services as an API to other devices, using ChatGPT app as an example. The following diagram show the communication between my laptop and IOS/iPadOS devices. On my laptop, it running two http services. One is the endpoint used to receive a query, and the purpose of the other one is to communicate with IOS/iPadOS devices. Since the IOS/iPadOS devices cannot provide an API service, we make Apple devices query question every 1 second and post the answer when the computation is done. This allows the convenience of Apple shortcut can extend to other devices.

image

If you want to use the following example of implementing ChatGPT app, modify the variable in the following image. image

Download

Run

step1: run the main service

python3 main.py

step2: start shortcut

Run ShortcutChatgptAPI shortcut app. This will run in an infinite loop but might be killed by iOS/iPadOS when running in the background.

step3: try to call the service

$ curl  -H "Content-Type: application/json" -X POST http://localhost:9001/question \
  -d '{"question": "What is GitHub? (reply in 1 sentence)"}'
  
# {"answer": "GitHub is a web-based platform for version control and collaboration that allows developers to host, manage, and share their code repositories.", "success": true}
import requests
url = 'http://localhost:9001/question'
def ask(text):
    x = requests.post(url, json = dict(question=text))
    return x.json()

response = ask("What is GitHub? (reply in 1 sentence)")
print('success:', response['success'])
# success: True
print('answer:', response['answer'])
# answer: GitHub is a web-based platform for version control and collaboration that allows developers to store, manage, and share their code repositories.

Done!!

Disclaimers

This repository is not reverse engineering and is only for experimental purposes only. The intention behind this is to integrate shortcut and host, with no malicious intent or commercial use. The app we use is for experimental purposes. Users should use the official tool/API to do further usage in their work. The repository owner and contributors shall not be held liable for any misuse or misinterpretation of the information presented here.

shortcut_chatgpt_api's People

Contributors

tony92151 avatar

Stargazers

Kenny Chang avatar Happydog avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.