正在查看: Tasker v6.5.11 应用的 APIOpenRouter.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
正在查看: Tasker v6.5.11 应用的 APIOpenRouter.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
package com.joaomgcd.oldtaskercompat.aigenerator;
import androidx.annotation.Keep;
import da.m;
import java.io.IOException;
import java.util.List;
import jk.d1;
import jk.i;
import jk.n0;
import kotlin.collections.r;
import lj.e0;
import lj.s;
import qj.l;
import rl.j0;
import rl.u;
import ul.k;
import ul.o;
import yj.h;
import yj.p;
public interface APIOpenRouter {
public static final Companion a = Companion.a;
@k({"Content-Type: application/json"})
@o("chat/completions")
Object a(@ul.a Companion.ChatCompletionsRequest chatCompletionsRequest, oj.d<? super Companion.ChatCompletionsResponse> dVar);
public static final class Companion {
static final Companion a = new Companion();
@Keep
public static final class ChatCompletionsResponse {
public static final int $stable = 8;
private final List<Choice> choices;
private final Long created;
private final OpenRouterErrorDetail error;
private final String f3id;
private final String model;
@nc.c("object")
private final String objectType;
@nc.c("system_fingerprint")
private final String systemFingerprint;
private final Usage usage;
@nc.c("user_id")
private final String userId;
@Keep
public static final class ErrorMetadata {
public static final int $stable = 0;
@nc.c("provider_name")
private final String providerName;
public ErrorMetadata(String str) {
this.providerName = str;
}
public static ErrorMetadata copy$default(ErrorMetadata errorMetadata, String str, int i, Object obj) {
if ((i & 1) != 0) {
str = errorMetadata.providerName;
}
return errorMetadata.copy(str);
}
public final String component1() {
return this.providerName;
}
public final ErrorMetadata copy(String str) {
return new ErrorMetadata(str);
}
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
return (obj instanceof ErrorMetadata) && p.d(this.providerName, ((ErrorMetadata) obj).providerName);
}
public final String getProviderName() {
return this.providerName;
}
public int hashCode() {
String str = this.providerName;
if (str == null) {
return 0;
}
return str.hashCode();
}
public String toString() {
return "ErrorMetadata(providerName=" + this.providerName + ")";
}
}
@Keep
public static final class Usage {
public static final int $stable = 0;
@nc.c("completion_tokens")
private final Integer completionTokens;
@nc.c("prompt_tokens")
private final Integer promptTokens;
@nc.c("total_tokens")
private final Integer totalTokens;
public Usage(Integer num, Integer num2, Integer num3) {
this.completionTokens = num;
this.promptTokens = num2;
this.totalTokens = num3;
}
public static Usage copy$default(Usage usage, Integer num, Integer num2, Integer num3, int i, Object obj) {
if ((i & 1) != 0) {
num = usage.completionTokens;
}
if ((i & 2) != 0) {
num2 = usage.promptTokens;
}
if ((i & 4) != 0) {
num3 = usage.totalTokens;
}
return usage.copy(num, num2, num3);
}
public final Integer component1() {
return this.completionTokens;
}
public final Integer component2() {
return this.promptTokens;
}
public final Integer component3() {
return this.totalTokens;
}
public final Usage copy(Integer num, Integer num2, Integer num3) {
return new Usage(num, num2, num3);
}
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (!(obj instanceof Usage)) {
return false;
}
Usage usage = (Usage) obj;
return p.d(this.completionTokens, usage.completionTokens) && p.d(this.promptTokens, usage.promptTokens) && p.d(this.totalTokens, usage.totalTokens);
}
public final Integer getCompletionTokens() {
return this.completionTokens;
}
public final Integer getPromptTokens() {
return this.promptTokens;
}
public final Integer getTotalTokens() {
return this.totalTokens;
}
public int hashCode() {
Integer num = this.completionTokens;
int hashCode = (num == null ? 0 : num.hashCode()) * 31;
Integer num2 = this.promptTokens;
int hashCode2 = (hashCode + (num2 == null ? 0 : num2.hashCode())) * 31;
Integer num3 = this.totalTokens;
return hashCode2 + (num3 != null ? num3.hashCode() : 0);
}
public String toString() {
return "Usage(completionTokens=" + this.completionTokens + ", promptTokens=" + this.promptTokens + ", totalTokens=" + this.totalTokens + ")";
}
}
public ChatCompletionsResponse() {
this(null, null, null, null, null, null, null, null, null, 511, null);
}
public final String component1() {
return this.f3id;
}
public final List<Choice> component2() {
return this.choices;
}
public final Long component3() {
return this.created;
}
public final String component4() {
return this.model;
}
public final String component5() {
return this.objectType;
}
public final String component6() {
return this.systemFingerprint;
}
public final Usage component7() {
return this.usage;
}
public final OpenRouterErrorDetail component8() {
return this.error;
}
public final String component9() {
return this.userId;
}
public final ChatCompletionsResponse copy(String str, List<Choice> list, Long l, String str2, String str3, String str4, Usage usage, OpenRouterErrorDetail openRouterErrorDetail, String str5) {
return new ChatCompletionsResponse(str, list, l, str2, str3, str4, usage, openRouterErrorDetail, str5);
}
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (!(obj instanceof ChatCompletionsResponse)) {
return false;
}
ChatCompletionsResponse chatCompletionsResponse = (ChatCompletionsResponse) obj;
return p.d(this.f3id, chatCompletionsResponse.f3id) && p.d(this.choices, chatCompletionsResponse.choices) && p.d(this.created, chatCompletionsResponse.created) && p.d(this.model, chatCompletionsResponse.model) && p.d(this.objectType, chatCompletionsResponse.objectType) && p.d(this.systemFingerprint, chatCompletionsResponse.systemFingerprint) && p.d(this.usage, chatCompletionsResponse.usage) && p.d(this.error, chatCompletionsResponse.error) && p.d(this.userId, chatCompletionsResponse.userId);
}
public final List<Choice> getChoices() {
return this.choices;
}
public final Long getCreated() {
return this.created;
}
public final OpenRouterErrorDetail getError() {
return this.error;
}
public final String getId() {
return this.f3id;
}
public final String getModel() {
return this.model;
}
public final String getObjectType() {
return this.objectType;
}
public final String getSystemFingerprint() {
return this.systemFingerprint;
}
public final Usage getUsage() {
return this.usage;
}
public final String getUserId() {
return this.userId;
}
public int hashCode() {
String str = this.f3id;
int hashCode = (str == null ? 0 : str.hashCode()) * 31;
List<Choice> list = this.choices;
int hashCode2 = (hashCode + (list == null ? 0 : list.hashCode())) * 31;
Long l = this.created;
int hashCode3 = (hashCode2 + (l == null ? 0 : l.hashCode())) * 31;
String str2 = this.model;
int hashCode4 = (hashCode3 + (str2 == null ? 0 : str2.hashCode())) * 31;
String str3 = this.objectType;
int hashCode5 = (hashCode4 + (str3 == null ? 0 : str3.hashCode())) * 31;
String str4 = this.systemFingerprint;
int hashCode6 = (hashCode5 + (str4 == null ? 0 : str4.hashCode())) * 31;
Usage usage = this.usage;
int hashCode7 = (hashCode6 + (usage == null ? 0 : usage.hashCode())) * 31;
OpenRouterErrorDetail openRouterErrorDetail = this.error;
int hashCode8 = (hashCode7 + (openRouterErrorDetail == null ? 0 : openRouterErrorDetail.hashCode())) * 31;
String str5 = this.userId;
return hashCode8 + (str5 != null ? str5.hashCode() : 0);
}
public String toString() {
return "ChatCompletionsResponse(id=" + this.f3id + ", choices=" + this.choices + ", created=" + this.created + ", model=" + this.model + ", objectType=" + this.objectType + ", systemFingerprint=" + this.systemFingerprint + ", usage=" + this.usage + ", error=" + this.error + ", userId=" + this.userId + ")";
}
public ChatCompletionsResponse(String str, List<Choice> list, Long l, String str2, String str3, String str4, Usage usage, OpenRouterErrorDetail openRouterErrorDetail, String str5) {
this.f3id = str;
this.choices = list;
this.created = l;
this.model = str2;
this.objectType = str3;
this.systemFingerprint = str4;
this.usage = usage;
this.error = openRouterErrorDetail;
this.userId = str5;
}
@Keep
public static final class OpenRouterErrorDetail {
public static final int $stable = 0;
private final Integer code;
private final String message;
private final ErrorMetadata metadata;
public OpenRouterErrorDetail(String str, Integer num, ErrorMetadata errorMetadata) {
this.message = str;
this.code = num;
this.metadata = errorMetadata;
}
public static OpenRouterErrorDetail copy$default(OpenRouterErrorDetail openRouterErrorDetail, String str, Integer num, ErrorMetadata errorMetadata, int i, Object obj) {
if ((i & 1) != 0) {
str = openRouterErrorDetail.message;
}
if ((i & 2) != 0) {
num = openRouterErrorDetail.code;
}
if ((i & 4) != 0) {
errorMetadata = openRouterErrorDetail.metadata;
}
return openRouterErrorDetail.copy(str, num, errorMetadata);
}
public final String component1() {
return this.message;
}
public final Integer component2() {
return this.code;
}
public final ErrorMetadata component3() {
return this.metadata;
}
public final OpenRouterErrorDetail copy(String str, Integer num, ErrorMetadata errorMetadata) {
return new OpenRouterErrorDetail(str, num, errorMetadata);
}
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (!(obj instanceof OpenRouterErrorDetail)) {
return false;
}
OpenRouterErrorDetail openRouterErrorDetail = (OpenRouterErrorDetail) obj;
return p.d(this.message, openRouterErrorDetail.message) && p.d(this.code, openRouterErrorDetail.code) && p.d(this.metadata, openRouterErrorDetail.metadata);
}
public final Integer getCode() {
return this.code;
}
public final String getMessage() {
return this.message;
}
public final ErrorMetadata getMetadata() {
return this.metadata;
}
public int hashCode() {
String str = this.message;
int hashCode = (str == null ? 0 : str.hashCode()) * 31;
Integer num = this.code;
int hashCode2 = (hashCode + (num == null ? 0 : num.hashCode())) * 31;
ErrorMetadata errorMetadata = this.metadata;
return hashCode2 + (errorMetadata != null ? errorMetadata.hashCode() : 0);
}
public String toString() {
return "OpenRouterErrorDetail(message=" + this.message + ", code=" + this.code + ", metadata=" + this.metadata + ")";
}
public OpenRouterErrorDetail(String str, Integer num, ErrorMetadata errorMetadata, int i, h hVar) {
this(str, num, (i & 4) != 0 ? null : errorMetadata);
}
}
public ChatCompletionsResponse(String str, List list, Long l, String str2, String str3, String str4, Usage usage, OpenRouterErrorDetail openRouterErrorDetail, String str5, int i, h hVar) {
this((i & 1) != 0 ? null : str, (i & 2) != 0 ? null : list, (i & 4) != 0 ? null : l, (i & 8) != 0 ? null : str2, (i & 16) != 0 ? null : str3, (i & 32) != 0 ? null : str4, (i & 64) != 0 ? null : usage, (i & 128) != 0 ? null : openRouterErrorDetail, (i & 256) == 0 ? str5 : null);
}
}
@Keep
public static final class Choice {
public static final int $stable = 0;
@nc.c("finish_reason")
private final String finishReason;
private final Integer index;
private final Message message;
public Choice(String str, Integer num, Message message) {
p.i(message, "message");
this.finishReason = str;
this.index = num;
this.message = message;
}
public static Choice copy$default(Choice choice, String str, Integer num, Message message, int i, Object obj) {
if ((i & 1) != 0) {
str = choice.finishReason;
}
if ((i & 2) != 0) {
num = choice.index;
}
if ((i & 4) != 0) {
message = choice.message;
}
return choice.copy(str, num, message);
}
public final String component1() {
return this.finishReason;
}
public final Integer component2() {
return this.index;
}
public final Message component3() {
return this.message;
}
public final Choice copy(String str, Integer num, Message message) {
p.i(message, "message");
return new Choice(str, num, message);
}
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (!(obj instanceof Choice)) {
return false;
}
Choice choice = (Choice) obj;
return p.d(this.finishReason, choice.finishReason) && p.d(this.index, choice.index) && p.d(this.message, choice.message);
}
public final String getFinishReason() {
return this.finishReason;
}
public final Integer getIndex() {
return this.index;
}
public final Message getMessage() {
return this.message;
}
public int hashCode() {
String str = this.finishReason;
int hashCode = (str == null ? 0 : str.hashCode()) * 31;
Integer num = this.index;
return ((hashCode + (num != null ? num.hashCode() : 0)) * 31) + this.message.hashCode();
}
public String toString() {
return "Choice(finishReason=" + this.finishReason + ", index=" + this.index + ", message=" + this.message + ")";
}
}
@Keep
public static final class Message {
public static final int $stable = 0;
private final String content;
private final String role;
public Message(String str, String str2) {
p.i(str, "role");
p.i(str2, "content");
this.role = str;
this.content = str2;
}
public static Message copy$default(Message message, String str, String str2, int i, Object obj) {
if ((i & 1) != 0) {
str = message.role;
}
if ((i & 2) != 0) {
str2 = message.content;
}
return message.copy(str, str2);
}
public final String component1() {
return this.role;
}
public final String component2() {
return this.content;
}
public final Message copy(String str, String str2) {
p.i(str, "role");
p.i(str2, "content");
return new Message(str, str2);
}
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (!(obj instanceof Message)) {
return false;
}
Message message = (Message) obj;
return p.d(this.role, message.role) && p.d(this.content, message.content);
}
public final String getContent() {
return this.content;
}
public final String getRole() {
return this.role;
}
public int hashCode() {
return (this.role.hashCode() * 31) + this.content.hashCode();
}
public String toString() {
return "Message(role=" + this.role + ", content=" + this.content + ")";
}
}
public static final class a extends IOException {
private final String i;
private final Integer q;
private final ChatCompletionsResponse.ErrorMetadata r;
public a(String str, Integer num, ChatCompletionsResponse.ErrorMetadata errorMetadata, int i, h hVar) {
this(str, (i & 2) != 0 ? null : num, (i & 4) != 0 ? null : errorMetadata);
}
public a(String str, Integer num, ChatCompletionsResponse.ErrorMetadata errorMetadata) {
super("OpenRouter API Error (Code " + num + "): " + str);
p.i(str, "errorMessage");
this.i = str;
this.q = num;
this.r = errorMetadata;
}
public a(com.joaomgcd.oldtaskercompat.aigenerator.APIOpenRouter.Companion.ChatCompletionsResponse.OpenRouterErrorDetail r3) {
throw new UnsupportedOperationException("Method not decompiled: com.joaomgcd.oldtaskercompat.aigenerator.APIOpenRouter.Companion.a.<init>(com.joaomgcd.oldtaskercompat.aigenerator.APIOpenRouter$Companion$ChatCompletionsResponse$OpenRouterErrorDetail):void");
}
}
@qj.f(c = "com.joaomgcd.oldtaskercompat.aigenerator.APIOpenRouter$Companion$generateText$3", f = "APIOpenRouter.kt", l = {m.f86mc}, m = "invokeSuspend")
static final class b extends l implements xj.p<n0, oj.d<? super String>, Object> {
int t;
final String u;
final String v;
final List<Message> w;
final String x;
final float y;
b(String str, String str2, List<Message> list, String str3, float f, oj.d<? super b> dVar) {
super(2, dVar);
this.u = str;
this.v = str2;
this.w = list;
this.x = str3;
this.y = f;
}
public final oj.d<e0> k(Object obj, oj.d<?> dVar) {
return new b(this.u, this.v, this.w, this.x, this.y, dVar);
}
public final Object r(Object obj) {
ChatCompletionsResponse chatCompletionsResponse;
vk.e0 d;
String q;
List<Choice> choices;
Choice choice;
Message message;
String content;
Object c = pj.b.c();
int i = this.t;
try {
if (i == 0) {
s.b(obj);
APIOpenRouter b = Companion.a.b(this.u);
String str = this.v;
Message message2 = str != null ? new Message("system", str) : null;
ChatCompletionsRequest chatCompletionsRequest = new ChatCompletionsRequest(this.x, message2 == null ? this.w : r.x0(r.d(message2), this.w), null, null, qj.b.b(this.y), null, 44, null);
this.t = 1;
obj = b.a(chatCompletionsRequest, this);
if (obj == c) {
return c;
}
} else {
if (i != 1) {
throw new IllegalStateException("call to 'resume' before 'invoke' with coroutine");
}
s.b(obj);
}
chatCompletionsResponse = (ChatCompletionsResponse) obj;
} catch (u e) {
j0 c2 = e.c();
chatCompletionsResponse = (c2 == null || (d = c2.d()) == null || (q = d.q()) == null) ? null : (ChatCompletionsResponse) wf.c.a().h(q, ChatCompletionsResponse.class);
}
ChatCompletionsResponse.OpenRouterErrorDetail error = chatCompletionsResponse != null ? chatCompletionsResponse.getError() : null;
if (error != null) {
throw new a(error);
}
if (chatCompletionsResponse == null || (choices = chatCompletionsResponse.getChoices()) == null || (choice = (Choice) r.f0(choices)) == null || (message = choice.getMessage()) == null || (content = message.getContent()) == null) {
throw new a("No error or success message gotten", null, null, 6, null);
}
return content;
}
public final Object l(n0 n0Var, oj.d<? super String> dVar) {
return k(n0Var, dVar).r(e0.a);
}
}
private Companion() {
}
public final Object a(String str, String str2, String str3, float f, List<Message> list, oj.d<? super String> dVar) {
return i.g(d1.b(), new b(str, str3, list, str2, f, null), dVar);
}
public final APIOpenRouter b(String str) {
p.i(str, "apiKey");
return (APIOpenRouter) new com.joaomgcd.taskerm.retrofit.d(APIOpenRouter.class, "https://openrouter.ai/api/v1/", str, (ji.r) null, new mg.k(10L, com.joaomgcd.oldtaskercompat.aigenerator.a.a.e()), 8, (h) null).d();
}
@Keep
public static final class ChatCompletionsRequest {
public static final int $stable = 8;
@nc.c("max_tokens")
private final Integer maxTokens;
private final List<Message> messages;
private final String model;
private final Boolean stream;
private final Double temperature;
@nc.c("top_p")
private final Double topP;
public ChatCompletionsRequest(String str, List<Message> list, Integer num, Boolean bool, Double d, Double d2) {
p.i(str, "model");
p.i(list, "messages");
this.model = str;
this.messages = list;
this.maxTokens = num;
this.stream = bool;
this.temperature = d;
this.topP = d2;
}
public static ChatCompletionsRequest copy$default(ChatCompletionsRequest chatCompletionsRequest, String str, List list, Integer num, Boolean bool, Double d, Double d2, int i, Object obj) {
if ((i & 1) != 0) {
str = chatCompletionsRequest.model;
}
if ((i & 2) != 0) {
list = chatCompletionsRequest.messages;
}
List list2 = list;
if ((i & 4) != 0) {
num = chatCompletionsRequest.maxTokens;
}
Integer num2 = num;
if ((i & 8) != 0) {
bool = chatCompletionsRequest.stream;
}
Boolean bool2 = bool;
if ((i & 16) != 0) {
d = chatCompletionsRequest.temperature;
}
Double d3 = d;
if ((i & 32) != 0) {
d2 = chatCompletionsRequest.topP;
}
return chatCompletionsRequest.copy(str, list2, num2, bool2, d3, d2);
}
public final String component1() {
return this.model;
}
public final List<Message> component2() {
return this.messages;
}
public final Integer component3() {
return this.maxTokens;
}
public final Boolean component4() {
return this.stream;
}
public final Double component5() {
return this.temperature;
}
public final Double component6() {
return this.topP;
}
public final ChatCompletionsRequest copy(String str, List<Message> list, Integer num, Boolean bool, Double d, Double d2) {
p.i(str, "model");
p.i(list, "messages");
return new ChatCompletionsRequest(str, list, num, bool, d, d2);
}
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (!(obj instanceof ChatCompletionsRequest)) {
return false;
}
ChatCompletionsRequest chatCompletionsRequest = (ChatCompletionsRequest) obj;
return p.d(this.model, chatCompletionsRequest.model) && p.d(this.messages, chatCompletionsRequest.messages) && p.d(this.maxTokens, chatCompletionsRequest.maxTokens) && p.d(this.stream, chatCompletionsRequest.stream) && p.d(this.temperature, chatCompletionsRequest.temperature) && p.d(this.topP, chatCompletionsRequest.topP);
}
public final Integer getMaxTokens() {
return this.maxTokens;
}
public final List<Message> getMessages() {
return this.messages;
}
public final String getModel() {
return this.model;
}
public final Boolean getStream() {
return this.stream;
}
public final Double getTemperature() {
return this.temperature;
}
public final Double getTopP() {
return this.topP;
}
public int hashCode() {
int hashCode = ((this.model.hashCode() * 31) + this.messages.hashCode()) * 31;
Integer num = this.maxTokens;
int hashCode2 = (hashCode + (num == null ? 0 : num.hashCode())) * 31;
Boolean bool = this.stream;
int hashCode3 = (hashCode2 + (bool == null ? 0 : bool.hashCode())) * 31;
Double d = this.temperature;
int hashCode4 = (hashCode3 + (d == null ? 0 : d.hashCode())) * 31;
Double d2 = this.topP;
return hashCode4 + (d2 != null ? d2.hashCode() : 0);
}
public String toString() {
return "ChatCompletionsRequest(model=" + this.model + ", messages=" + this.messages + ", maxTokens=" + this.maxTokens + ", stream=" + this.stream + ", temperature=" + this.temperature + ", topP=" + this.topP + ")";
}
public ChatCompletionsRequest(String str, List list, Integer num, Boolean bool, Double d, Double d2, int i, h hVar) {
this(str, list, (i & 4) != 0 ? null : num, (i & 8) != 0 ? null : bool, (i & 16) != 0 ? null : d, (i & 32) != 0 ? null : d2);
}
}
}
}