Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

科大讯飞星火模型 API && API 重构 #29

Closed
hotip opened this issue Aug 21, 2023 · 8 comments
Closed

科大讯飞星火模型 API && API 重构 #29

hotip opened this issue Aug 21, 2023 · 8 comments
Assignees

Comments

@hotip
Copy link
Contributor

hotip commented Aug 21, 2023

LLMProvider api 设计不太适合当前 LLM 模型需求。

/**
 * LLMProvider provide only session-free interfaces
 *
 * It's LLMProvider's responsibility to maintain the network connection
 * But the chat session is maintained by the client
 *
 * The implementations should provide a way to convert the response to a ChatSession
 */
abstract class LLMProvider<M : ChatMessage> {

    // observe response
    abstract val response: Flow<ChatSession<M>>
    // send request
    abstract fun textComplete(session: ChatSession<ChatMessage>)
    // send image request
    abstract fun imageGenerate(prompt: String): Flow<ChatSession<M>>
    // response json to ChatSession Data transformer
    protected abstract fun responseToChatSession(sendingSession: ChatSession<M>, responseBody: String): ChatSession<M>
}

https://gist.github.com/hotip/0514521ffee37c3b49cef52dbad96f16

@phodal
Copy link
Member

phodal commented Aug 21, 2023

能直接来个 PR 吗?我这里没有 API,没法测试。

需要修改:

  1. 添加新的 AI Engine

val AI_ENGINES = arrayOf("OpenAI", "Custom", "Azure")

  1. 配置新的 provider:

class LLMProviderFactory {
private val aiEngine: String = AutoDevSettingsState.getInstance().aiEngine ?: DEFAULT_AI_ENGINE
fun connector(project: Project): LLMProvider {
return when (aiEngine) {
"OpenAI" -> project.getService(OpenAIProvider::class.java)
"Custom" -> project.getService(CustomLLMProvider::class.java)
"Azure" -> project.getService(AzureOpenAIProvider::class.java)
else -> project.getService(OpenAIProvider::class.java)
}
}
}

不过,看他的代码,感觉还需要一个新的配置窗口才行?

@hotip
Copy link
Contributor Author

hotip commented Aug 21, 2023

是要添加新的配置项,有三个配置。
改动有点大,涉及到 data class,我晚点看看怎么加上去

@phodal
Copy link
Member

phodal commented Aug 21, 2023

可以把配置项列出来吗?我看要不要加一个新的配置页

@hotip
Copy link
Contributor Author

hotip commented Aug 21, 2023

都在这了

    data class AuthConfig(
        val appId: String,
        val apiKey: String,
        val apiSecret: String,
    )

@phodal
Copy link
Member

phodal commented Aug 21, 2023

666,那等你加完,我再看看会不会太长

@hotip
Copy link
Contributor Author

hotip commented Aug 21, 2023

可以考虑只出当前选中的模型的参数。并把输入也 sheme 化

@phodal
Copy link
Member

phodal commented Aug 21, 2023

嗯,嗯,方法挺好的

@phodal phodal closed this as completed in cca35c6 Aug 21, 2023
@hotip
Copy link
Contributor Author

hotip commented Aug 21, 2023

重构起 issue 吧

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants