我正在使用 llama-index 基于文档创建一个非常简单的问答应用程序。此前,我曾将其与 OpenAI 一起使用。现在我想尝试不使用外部 API,因此我尝试此链接中的Hugging Face 示例。
它在链接的示例中说:“请注意,为了获得完全私人的体验,还需要设置本地嵌入模型(此处的示例)。” 我假设下面给出的示例是所引用的示例。因此,很自然地,我尝试复制该示例(此处为更完整的示例)。
这是我的代码:
from pathlib import Path
import gradio as gr
import sys
import logging
import os
from llama_index.llms import HuggingFaceLLM
from llama_index.prompts.prompts import SimpleInputPrompt
logging.basicConfig(stream=sys.stdout, level=logging.DEBUG)
logging.getLogger().addHandler(logging.StreamHandler(stream=sys.stdout))
from llama_index import SimpleDirectoryReader, VectorStoreIndex, ServiceContext, load_index_from_storage, StorageContext
storage_path = "storage/"
docs_path="docs"
def construct_index(directory_path):
max_input_size = 4096
num_outputs = 512
#max_chunk_overlap = 20
chunk_overlap_ratio = 0.1
chunk_size_limit = 600
#prompt_helper = PromptHelper(max_input_size, num_outputs, chunk_overlap_ratio, chunk_size_limit=chunk_size_limit)
system_prompt = """<|SYSTEM|># StableLM Tuned …
Run Code Online (Sandbox Code Playgroud) python huggingface-transformers huggingface llama-index large-language-model
是否可以混合图像和文本并将其作为彩信发送?UIActivityViewController
将与下方的文本共享图像,但无论我如何订购文本和图像,图像始终显示在顶部,文本显示在底部.如果不可能UIActivityViewController
,还有另外一种方法吗?
我正在尝试使用的代码:
NSArray *activityItems = @[smallImage, @"Love", mediumImage, @"You", largeImage];
NSArray *applicationActivities = nil;
NSArray *excludeActivities = nil;
UIActivityViewController * activityController = [[UIActivityViewController alloc] initWithActivityItems:activityItems applicationActivities:applicationActivities];
activityController.excludedActivityTypes = excludeActivities;
[self presentViewController:activityController animated:YES completion:nil];
Run Code Online (Sandbox Code Playgroud)
它产生了这个结果:
但这就是我想要的:
我正在尝试将我的pod内部通信更新到最新版本.pod显示它需要更新但它拒绝更新.
# pod outdated
Updating spec repo `master`
Analyzing dependencies
The following pod updates are available:
- Intercom 2.3.21 -> 2.3.21 (latest version 3.0.11)
- SevenSwitch 1.4.0 -> 1.4.0 (latest version 2.0.0)
Run Code Online (Sandbox Code Playgroud)
但是当我去更新它时:
# pod outdated
Updating spec repo `master`
Analyzing dependencies
The following pod updates are available:
- Intercom 2.3.21 -> 2.3.21 (latest version 3.0.11)
- SevenSwitch 1.4.0 -> 1.4.0 (latest version 2.0.0)
hopebox:Sonar Mobile michaelleonetti$ pod update Intercom
Updating local specs repositories
Analyzing dependencies
Downloading dependencies
Using ISO8601 …
Run Code Online (Sandbox Code Playgroud) 我有一个程序通过EAGI与Asterisk通信.Asterisk打开我的Node.js应用程序并通过STDIN发送数据,程序通过STDOUT发送Asterisk命令.当用户挂断时,Node.js进程会收到一个SIGHUP命令.这是为了清洁退出而截获的.此功能正常运行.
Asterisk还在fd 3(STDERR + 1)上发送RAW音频数据.Node.js进程正确拦截数据,并能够读取音频,转换它或其他任何需要完成的事情.但是,当在fd 3上创建createReadStream时,Node.js进程将不会退出并迅速成为Zombie.如果我注释掉createReadStream代码,Node.js将按预期退出.
如何使用process.exit()函数让Node.js退出?我正在使用Node.js版本v0.10.30.
Node.js createReadStream代码:
// It was success
this.audioInStream = fs.createReadStream( null, { 'fd' : 3 } );
// Pipe the audio stream to a blackhole for now so it doesn't get queued up
this.audioInStream.pipe( blackhole() );
Run Code Online (Sandbox Code Playgroud)
SIGHUP代码:
process
.on( 'SIGHUP', function() {
log.message.info( "[%s] Asterisk process hung up.", that.callerid );
that.exitWhenReady();
} );
Run Code Online (Sandbox Code Playgroud)
exitWhenReady函数
Index.prototype.exitWhenReady = function() {
if( !this.canExit )
return;
log.message.info( "[%s] Exiting program successfully.", this.callerid );
// Get rid of our …
Run Code Online (Sandbox Code Playgroud) 跟踪用户在App中查看屏幕(或与UIView交互)使用的App使用时间和时间的最佳方法是什么?谷歌分析似乎做得很好,但我想在应用程序内部使用的数字来解锁应用程序的项目和区域.
我不太熟悉Node.js中的保留周期来自Objective-C/iOS,但是我写了一些代码,我希望这些代码不会导致保留周期.我不确定V8如何智能地处理垃圾收集或者我应该对此有多聪明!
在我的示例中,我创建了一个对象,该对象应该处理数据连接并将该数据反馈给父对象.为此,我使用EventEmitter .on函数来注册父对象函数.处理完所有数据后,父对象会被释放,但之后会在父对象和子对象之间创建一个保留周期吗?示例代码
// Create the SonarData with the necessary information
this.sonardata = new SonarData( this.key, this.size )
// Hook events
.on( 'error', this.handleError.bind( this ) )
.on( 'done', this.handleDone.bind( this ) )
.on( 'data', this.handleData.bind( this ) );
Run Code Online (Sandbox Code Playgroud) 我不确定我的应用程序发生了什么变化。由于某种原因,最近当我尝试开发它时,我的应用程序上的导航栏开始消失,然后当我向下滚动时重新出现。这是演示这一点的屏幕截图。
是什么让我的导航栏消失了?
应用程序打开到左侧的屏幕截图,然后向下滚动以显示右侧的屏幕截图。
这是一个全新的导航控制器,我在 Storyboard 上设置并在初始视图控制器中设置。新控制器的实际 swift 代码如下。
import UIKit
class NewsViewController: UITableViewController {
override func viewDidLoad() {
super.viewDidLoad()
// Uncomment the following line to preserve selection between presentations
// self.clearsSelectionOnViewWillAppear = false
// Uncomment the following line to display an Edit button in the navigation bar for this view controller.
// self.navigationItem.rightBarButtonItem = self.editButtonItem
}
// MARK: - Table view data source
override func numberOfSections(in tableView: UITableView) -> Int {
// #warning Incomplete implementation, return the number of sections …
Run Code Online (Sandbox Code Playgroud) 目标是在将文本共享到来自应用程序的SMS消息以及电子邮件中时能够插入带有文本的图像.就像它在下面的图片中一样.当我尝试使用UIActivityViewController共享图像时,图像显示在下一行而不是文本旁边.是否可以将图像嵌入文本和电子邮件中,如内置的表情符号文本?
我正在尝试使用MingW(msys2)在Windows上编译程序,但使用j0函数失败。在Linux上,编译没有问题。当我在编译器上使用-std = c ++ 11标志时,似乎很讨厌。如何使它正确编译并打开-std = c ++ 11标志?
样例代码:
#include <cmath>
int main( int argc, char *argv[] )
{
float test = j0( 5 );
}
Run Code Online (Sandbox Code Playgroud)
输出量
$ g++ -std=c++11 test.cpp -o test
test.cpp: In function 'int main(int, char**)':
test.cpp:6:21: error: 'j0' was not declared in this scope
float test = j0( 5 );
Run Code Online (Sandbox Code Playgroud) ios ×4
javascript ×2
node.js ×2
objective-c ×2
sms ×2
analytics ×1
c++11 ×1
cmath ×1
cocoapods ×1
emoji ×1
eventemitter ×1
events ×1
exit ×1
huggingface ×1
llama-index ×1
mingw ×1
mms ×1
python ×1
retain-cycle ×1
storyboard ×1
stream ×1
swift ×1
windows ×1
xcode ×1