小编Mik*_*tti的帖子

为什么 llama-index 在使用 Hugging Face 本地嵌入模型时仍然需要 OpenAI 密钥?

我正在使用 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

13
推荐指数
1
解决办法
1万
查看次数

UIActivityViewController混合文本和图像并保持顺序

是否可以混合图像和文本并将其作为彩信发送?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)

它产生了这个结果: 结果产生了

但这就是我想要的: 我想要的是

sms mms ios uiactivityviewcontroller

6
推荐指数
0
解决办法
765
查看次数

pod没有更新包但显示过时

我正在尝试将我的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)

cocoapods

6
推荐指数
0
解决办法
148
查看次数

Node.js process.exit()不会在createReadStream打开的情况下退出

我有一个程序通过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)

javascript stream exit node.js

4
推荐指数
1
解决办法
4339
查看次数

跟踪UIViewController(如Google Analytics)上的用户使用时间和时间

跟踪用户在App中查看屏幕(或与UIView交互)使用的App使用时间和时间的最佳方法是什么?谷歌分析似乎做得很好,但我想在应用程序内部使用的数字来解锁应用程序的项目和区域.

analytics objective-c usage-statistics ios

3
推荐指数
1
解决办法
1839
查看次数

将子对象的父对象添加到侦听器会导致Node.js中的保留周期吗?

我不太熟悉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)

javascript events node.js eventemitter retain-cycle

3
推荐指数
1
解决办法
282
查看次数

为什么我的导航栏在 ViewController 上消失,然后当我向下滚动时又重新出现?

我不确定我的应用程序发生了什么变化。由于某种原因,最近当我尝试开发它时,我的应用程序上的导航栏开始消失,然后当我向下滚动时重新出现。这是演示这一点的屏幕截图。

是什么让我的导航栏消失了?

应用程序打开到左侧的屏幕截图,然后向下滚动以显示右侧的屏幕截图。

当向上滚动时当向下滚动时

这是一个全新的导航控制器,我在 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)

xcode storyboard uinavigationcontroller ios swift

1
推荐指数
1
解决办法
1203
查看次数

iOS在Emoji等消息中与文本共享图像

目标是在将文本共享到来自应用程序的SMS消息以及电子邮件中时能够插入带有文本的图像.就像它在下面的图片中一样.当我尝试使用UIActivityViewController共享图像时,图像显示在下一行而不是文本旁边.是否可以将图像嵌入文本和电子邮件中,如内置的表情符号文本?内联表情符号

sms objective-c ios emoji

0
推荐指数
1
解决办法
1235
查看次数

mingw C ++无法编译j0函数

我正在尝试使用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)

windows mingw cmath c++11

0
推荐指数
1
解决办法
370
查看次数