Skip to main content

2 posts tagged with "chatgpt"

View All Tags

My Awesome ChatGPT

· 3 min read

Overview​

  • The programmers who are good at asking questions and quickly determining if the answers are right or wrong will be the ones who survive.
  • Here's a list of repositories that can be used in the field, not just for development tips.

aicommits​

src/utils/openai.ts#L7
const promptTemplate =
"Write an insightful but concise Git commit message in a complete sentence in present tense for the following diff without prefacing it with anything:";

node chatgpt​

const completionParams = {
temperature: 0.7,
top_p: 1,
frequency_penalty: 0,
presence_penalty: 0,
};

tiktoken​

  • You may need to get the exact number of tokens to use the openai API.
  • You should use openai/tiktoken, but it's Python.
  • dqbd/tiktoken already has a node wrapper already out there. 3.5 Turbo support
import { encoding_for_model as encodingForModel } from "@dqbd/tiktoken";

const encoder = encodingForModel("gpt-3.5-turbo");
const tokenLength = encoder.encode("YOUR_CHAT").length;

chatgpt-retrieval-plugin​

openai/chatgpt-retrieval-plugin

  • ai-plugin.json in the .well-known path acts as a manifest.json
  • Openapi.yaml in the same path for this endpoint specification
  • There are four types of authentication: none | user_http | service_http | oauth.
  • For simple services, service_http seems to be sufficient, user_http requires the customer to enter an API key, and oauth requires additional permissions such as search:read.
  • It seems to use Vector DB for document similarity comparison, but there is no proper Node.js wrapper for it, so it can be implemented in Redis, but you need the Redisearch module.

ChatGPT use cases

· 2 min read

Overview​

Here's a list of use cases where you can get past the hype and actually use it for something useful.

Extracting regular expressions​

Creating regular expressions usually involves a lot of testing. I usually put the desired text in regexr, regex101, and match the negative/positive lookahead from memory, and use negative/positive lookbehind, but often find that negative lookbehind is not supported by different programming versions/languages.

Now I ask ChatGPT. Suppose you want to extract the package name from the package update history below.

Hello GPT.

Can you give me a regex pattern for getting to-be result?

as-is:
Orignal content


to-be:
Refined string #1
Refined string #2
...and so on.

It will get it for you.

Writing documentation with code​

If you want your code to be documented, put it in and ask it to create a README.md.

Can you write a README.md with this code?

It will get it for you.

Create an Object Validation Schema with the interface​

Let's create a Joi Schema with a TypeScript interface.

Create a Query DSL with Raw SQL​

Pass in a raw query and ask it to create a query DSL and query helper syntax.

Create a DDL with Data​

Pass in a query and ask it to generate a table schema query like the interface example above.

See​

awesome is now live. https://github.com/f/awesome-chatgpt-prompts