我正在制作一个 Python 脚本以通过其 API 使用 OpenAI。但是,我收到此错误:
openai.error.RateLimitError:您超出了当前配额,请检查您的计划和账单详细信息
我的脚本如下:
#!/usr/bin/env python3.8
# -*- coding: utf-8 -*-
import openai
openai.api_key = "<My PAI Key>"
completion = openai.ChatCompletion.create(
model="gpt-3.5-turbo",
messages=[
{"role": "user", "content": "Tell the world about the ChatGPT API in the style of a pirate."}
]
)
print(completion.choices[0].message.content)
Run Code Online (Sandbox Code Playgroud)
我正在声明 shebang python3.8,因为我正在使用pyenv。我认为它应该可以工作,因为我做了 0 个 API 请求,所以我假设我的代码中有错误。
我收到此错误无法找到模块'../lib/completion'但是我已经安装完成并且lib.file存在于lib文件中.
->gulp compile
module.js:327
throw err;
^
Error: Cannot find module '../lib/completion'
at Function.Module._resolveFilename (module.js:325:15)
at Function.Module._load (module.js:276:25)
at Module.require (module.js:353:17)
at require (internal/module.js:12:17)
at Object.<anonymous> (D:\wamp23\www\mfe\ref\gulpfile.js:13:18)
at Module._compile (module.js:409:26)
at Object.Module._extensions..js (module.js:416:10)
at Module.load (module.js:343:32)
at Function.Module._load (module.js:300:12)
at Module.require (module.js:353:17)
at require (internal/module.js:12:17)
Run Code Online (Sandbox Code Playgroud) 我已经处理了这个问题差不多一个月了,我感到很沮丧,任何帮助都会非常感激.
我正在尝试为我的takenote命令编写一个小部件.小部件的目的是将文件~/notes夹中的所有markdown文件提供fzf给用户,以便用户可以选择其中一个并开始编辑它.在用户输入takenote并按下之后,<tab>我希望小部件能够运行.
这是_takenote.zsh小部件定义:
#compdef takenote
local file=$( find -L "$HOME/notes/" -print 2> /dev/null | fzf-tmux +m )
zle reset-prompt
compadd $file
return 1
Run Code Online (Sandbox Code Playgroud)
不幸的是,上面的代码不起作用,因为zle reset-prompt,如果我删除它然后结果将是这样的:
选择文件后,它将变成:
如您所见,将破坏提示和命令本身.在我看来,我需要做的是zle reset-prompt
在调用之前做一个compadd但这只有在我将函数绑定到一个键时才能工作,否则,我将得到以下错误:
只有在ZLE处于活动状态时才能调用小部件
我试图编写一个将其他Shell实用程序包装到单个CLI中的Shell脚本实用程序,并试图使Shell完成在zsh和bash中工作。
例如,假设CLI名为util:
util aws [...args] #=> runs aws
util docker [...args] #=> runs docker
util terraform [...args] #=> runs terraform
Run Code Online (Sandbox Code Playgroud)
理想情况下,我想要的是zsh和bash补全中的一种方式,它能够独立于包装脚本的补全实现说“像其他命令Y一样完成此子命令X”。
就像是:
compdef 'util aws'='aws'
compdef 'util docker'='docker'
compdef 'util terraform'='terraform'
Run Code Online (Sandbox Code Playgroud)
扩展目标将是允许对另一个二进制文件中的子命令完成任意子命令:
util aws [...args] #=> completes against `aws`
util ecr [...args] #=> completes against `aws ecr`
Run Code Online (Sandbox Code Playgroud)
有可能吗?我一直在尝试模拟单个二进制文件的完成脚本,但是在编写其他完成脚本的方式上有很大的不同。
我是Swift和SpriteKit的新手.很多SpriteKit动作的样本都在Objective C中,我无法在Swift中映射,也无法工作.
如果运行SKAction,并且在SKAction完成后想要做其他事情,我如何在Swift中做到这一点?
spaceMan.runAction(spaceManDeathAnimation, completion: {
println("red box has faded out")
})
Run Code Online (Sandbox Code Playgroud)
任何想法将不胜感激.
编辑:
for i in 0...29 {
textures.append(SKTexture(imageNamed: "spaceManDeath_\(i)"))
}
spaceManDeathAnimation = SKAction.repeatActionForever(SKAction.animateWithTextures(textures, timePerFrame: 0.15625))
Run Code Online (Sandbox Code Playgroud) 如此答案所示,可以使用bash中的readReadline(-e)通过使用向上和向下键返回以前的历史记录项:
#! /usr/bin/env bash
while IFS="" read -p "input> " -e line; do
history -s "$line" # append $line to local history
done
Run Code Online (Sandbox Code Playgroud)
在zsh中执行此操作的正确方法是什么?(在循环中获取用户输入并允许上/下键历史记录完成).这不起作用:
#! /usr/bin/env zsh
while IFS="" vared -p "input> " -c line; do
done
Run Code Online (Sandbox Code Playgroud)
我认为在zsh中的脚本默认禁用历史记录完成.另外,我不希望历史记录来自shell,而是来自脚本中输入的输入.
我有Qt Creator 4.1.0 ubuntu 16.04.我在完成和代码突出显示方面遇到了问题.我需要等待3-4秒(或更长时间)才能完成代码并突出显示关键字.怎么了?Qt Creator 3.6.0正常工作.
使用Elasticsearch完成建议器,我在返回与单字查询匹配的多字输入建议时遇到问题.
结构示例:
PUT /test_index/
{
"mappings": {
"item": {
"properties": {
"test_suggest": {
"type": "completion",
"index_analyzer": "whitespace",
"search_analyzer": "whitespace",
"payloads": false
}
}
}
}
}
PUT /test_index/item/1
{
"test_suggest": {
"input": [
"cat dog",
"elephant"
]
}
}
Run Code Online (Sandbox Code Playgroud)
工作查询:
POST /test_index/_suggest
{
"test_suggest":{
"text":"cat",
"completion": {
"field" : "test_suggest"
}
}
}
Run Code Online (Sandbox Code Playgroud)
结果
{
"_shards": {
"total": 5,
"successful": 5,
"failed": 0
},
"test_suggest": [
{
"text": "cat",
"offset": 0,
"length": 3,
"options": [
{
"text": "cat dog",
"score": …Run Code Online (Sandbox Code Playgroud) 我希望--flags在我的gradle完成脚本中允许完成其他输入之后,但_arguments似乎需要这样做
描述选项标志的规范必须在描述分析行的非选项("位置"或"正常")参数的规范之前(来自zsh完成文档)
换句话说:command foo --o[TAB]什么都不做,但command --o[TAB]工作正常.有没有办法配置_arguments或我需要使用其他控制功能?
注意:在我的情况下,单独的完成功能似乎不是一个选项,因为输入不在固定列表中(gradle任务是任意的,可以指定多个,gradle myfoo mybar --o[TAB]必须工作).
Kotlin 自动完成功能在 Android Studio 中不起作用。Java 和 XML 自动完成功能正常工作,但 Kotlin 不工作。
Kotlin 不工作示例:
XML 工作示例:
completion ×10
zsh ×4
autocomplete ×2
android ×1
autosuggest ×1
bash ×1
chatgpt-api ×1
fzf ×1
gulp ×1
gulp-sass ×1
handler ×1
history ×1
kotlin ×1
node.js ×1
openai-api ×1
prompt ×1
python ×1
qt-creator ×1
shell ×1
skaction ×1
sprite-kit ×1
swift ×1
widget ×1
zsh-zle ×1